Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graffy/stream

Package Overview
Dependencies
Maintainers
1
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graffy/stream - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0

2

package.json

@@ -5,3 +5,3 @@ {

"author": "aravind (https://github.com/aravindet)",
"version": "0.11.0",
"version": "0.12.0",
"main": "dst/index.js",

@@ -8,0 +8,0 @@ "source": "src/index.js",

@@ -11,2 +11,3 @@ # Graffy Stream

Imagine the event emitter:
```js

@@ -17,2 +18,3 @@ websocket.addEventListener('message', callback);

We would like to feed this stream of messages into an AsyncIterable, so we can do:
```js

@@ -24,2 +26,3 @@ for await (const message of messages) {

```
and do stuff. We might also want to call `removeEventListener` when we break (or return or throw) out of the loop.

@@ -77,3 +80,3 @@

eventSource.close();
}
};
});

@@ -91,15 +94,18 @@ ```

```js
const stream = makeStream(push => {
eventSource.on('event', event => {
const wait = push(event);
if (wait) {
eventSource.pause();
wait.then(() => eventSource.resume());
}
});
const stream = makeStream(
push => {
eventSource.on('event', event => {
const wait = push(event);
if (wait) {
eventSource.pause();
wait.then(() => eventSource.resume());
}
});
return () => eventSource.close();
}, { highWatermark: 255, lowWatermark: 4 });
return () => eventSource.close();
},
{ highWatermark: 255, lowWatermark: 4 },
);
```
If there are more than `highWatermark` unconsumed events, `push()` will return a Promise `wait`. As the consumer catches up and the number of unconsumed events fall below `lowWatermark`, this promise will resolve.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc