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 3.0.2 to 4.0.0

14

index.js

@@ -20,12 +20,12 @@ const AsyncIterableStream = require('async-iterable-stream');

end(name) {
close(name) {
this._write(name, undefined, true);
}
endAll() {
this._mainStream.end();
closeAll() {
this._mainStream.close();
}
createAsyncIterator(name) {
let mainStreamIterator = this._mainStream.createAsyncIterator();
createAsyncIterator(name, timeout) {
let mainStreamIterator = this._mainStream.createAsyncIterator(timeout);
return {

@@ -58,4 +58,4 @@ next: async () => {

createAsyncIterator() {
return this._streamDemux.createAsyncIterator(this.name);
createAsyncIterator(timeout) {
return this._streamDemux.createAsyncIterator(this.name, timeout);
}

@@ -62,0 +62,0 @@ }

{
"name": "stream-demux",
"version": "3.0.2",
"version": "4.0.0",
"description": "An iterable asynchronous stream demultiplexer.",

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

"dependencies": {
"async-iterable-stream": "^2.0.3",
"writable-async-iterable-stream": "^3.0.2"
"async-iterable-stream": "^3.0.0",
"writable-async-iterable-stream": "^4.0.0"
}
}

@@ -5,3 +5,3 @@ # 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 `DemuxedAsyncIterableStream` (base type `AsyncIterableStream`).
The `StreamDemux` class returns streams of class `DemuxedAsyncIterableStream` (base class `AsyncIterableStream`).
See https://github.com/SocketCluster/async-iterable-stream

@@ -38,6 +38,5 @@

// Consume data from 'def' stream.
// Can also work with a while loop for
// older environments.
// Can have multiple loops consuming the same
// stream at the same time.
// Can also work with a while loop for older environments.
// Can have multiple loops consuming the same stream at
// the same time.
let asyncIterator = demux.stream('def').getAsyncIterator();

@@ -57,4 +56,4 @@ while (true) {

}
demux.end('abc');
demux.end('def');
demux.close('abc');
demux.close('def');
})();

@@ -61,0 +60,0 @@

@@ -40,4 +40,4 @@ const assert = require('assert');

}
demux.end('hello');
demux.end('abc');
demux.close('hello');
demux.close('abc');
})();

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

}
demux.end('hello');
demux.close('hello');
})();

@@ -119,3 +119,3 @@

}
demux.end('hello');
demux.close('hello');
})();

@@ -139,3 +139,3 @@

it('should support ending all streams using a single endAll command', async () => {
it('should support closing all streams using a single closeAll command', async () => {
(async () => {

@@ -147,3 +147,3 @@ for (let i = 0; i < 10; i++) {

}
demux.endAll();
demux.closeAll();
})();

@@ -173,3 +173,3 @@

it('should support resuming stream consumption after the stream has been ended', async () => {
it('should support resuming stream consumption after the stream has been closed', async () => {
(async () => {

@@ -180,3 +180,3 @@ for (let i = 0; i < 10; i++) {

}
demux.end('hello');
demux.close('hello');
})();

@@ -196,3 +196,3 @@

}
demux.end('hello');
demux.close('hello');
})();

@@ -208,3 +208,3 @@

it('should support resuming stream consumption after the stream has been ended using endAll', async () => {
it('should support resuming stream consumption after the stream has been closed using closeAll', async () => {
(async () => {

@@ -215,3 +215,3 @@ for (let i = 0; i < 10; i++) {

}
demux.endAll();
demux.closeAll();
})();

@@ -231,3 +231,3 @@

}
demux.endAll();
demux.closeAll();
})();

@@ -249,3 +249,3 @@

}
demux.end('hello');
demux.close('hello');
})();

@@ -265,6 +265,6 @@

it('should not resolve stream.once() when stream is ended', async () => {
it('should not resolve stream.once() when stream is closed', async () => {
(async () => {
await wait(10);
demux.end('hello');
demux.close('hello');
})();

@@ -284,5 +284,31 @@

it('should support stream.next() method with end command', async () => {
it('should support the stream.once() method with timeout', async () => {
(async () => {
for (let i = 0; i < 3; i++) {
await wait(20);
demux.write('hello', 'world' + i);
}
demux.close('hello');
})();
let substream = demux.stream('hello');
let packet = await substream.once(30);
assert.equal(packet, 'world0');
let error;
packet = null;
try {
packet = await substream.once(10);
} catch (err) {
error = err;
}
assert.notEqual(error, null);
assert.equal(error.name, 'TimeoutError');
assert.equal(packet, null);
});
it('should support stream.next() method with close command', async () => {
(async () => {
for (let i = 0; i < 3; i++) {
await wait(10);

@@ -292,3 +318,3 @@ demux.write('hello', 'world' + i);

await wait(10);
demux.end('hello');
demux.close('hello');
})();

@@ -311,3 +337,3 @@

it('should support stream.next() method with endAll command', async () => {
it('should support stream.next() method with closeAll command', async () => {
(async () => {

@@ -317,3 +343,3 @@ await wait(10);

await wait(10);
demux.endAll();
demux.closeAll();
})();

@@ -320,0 +346,0 @@

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