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

stream-demux

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-demux - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

6

package.json
{
"name": "stream-demux",
"version": "1.2.1",
"version": "1.2.2",
"description": "An iterable asynchronous stream demultiplexer.",

@@ -31,5 +31,5 @@ "main": "index.js",

"dependencies": {
"async-iterable-stream": "^1.0.1",
"writable-async-iterable-stream": "^1.0.9"
"async-iterable-stream": "^1.0.3",
"writable-async-iterable-stream": "^1.1.0"
}
}

@@ -5,5 +5,13 @@ # stream-demux

Lets you write data to multiple async iterable streams from a central place without keeping any references to those streams.
The `StreamDemux` class returns streams of type `AsyncIterableStream`.
See https://github.com/SocketCluster/async-iterable-stream
# Usage
## Installation
```
npm install stream-demux
```
## Usage
```js

@@ -37,5 +45,14 @@ let demux = new StreamDemux();

})();
// Utility function for using setTimeout() with async/await.
function wait(duration) {
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, duration);
});
}
```
# Goal
## Goal

@@ -42,0 +59,0 @@ The goal of this module is to efficiently distribute data to a large number of named asynchronous streams while facilitating programming patterns which decrease the probability of memory leaks.

@@ -59,3 +59,3 @@ const assert = require('assert');

it('should support iteraring over a single substream from multiple consumers at the same time', async () => {
it('should support iterating over a single substream from multiple consumers at the same time', async () => {
(async () => {

@@ -96,2 +96,23 @@ for (let i = 0; i < 10; i++) {

});
it('should support the stream.once() method', async () => {
(async () => {
for (let i = 0; i < 10; i++) {
await wait(10);
demux.write('hello', 'world' + i);
}
demux.end('hello');
})();
let substream = demux.stream('hello');
let packet = await substream.once();
assert.equal(packet, 'world0');
packet = await substream.once();
assert.equal(packet, 'world1');
packet = await substream.once();
assert.equal(packet, 'world2');
});
});
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