stream-demux
Advanced tools
Comparing version 1.3.0 to 1.3.1
12
index.js
@@ -18,6 +18,10 @@ const AsyncIterableStream = require('async-iterable-stream'); | ||
end(name) { | ||
this.mainStream.write({ | ||
name, | ||
data: END_SYMBOL | ||
}); | ||
if (name === undefined) { | ||
this.mainStream.end(); | ||
} else { | ||
this.mainStream.write({ | ||
name, | ||
data: END_SYMBOL | ||
}); | ||
} | ||
} | ||
@@ -24,0 +28,0 @@ |
{ | ||
"name": "stream-demux", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "An iterable asynchronous stream demultiplexer.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -110,2 +110,34 @@ const assert = require('assert'); | ||
it('should support ending all streams using a single command', async () => { | ||
(async () => { | ||
for (let i = 0; i < 10; i++) { | ||
await wait(10); | ||
demux.write('hello', 'world' + i); | ||
demux.write('abc', 'def' + i); | ||
} | ||
demux.end(); | ||
})(); | ||
let receivedHelloPackets = []; | ||
let receivedAbcPackets = []; | ||
await Promise.all([ | ||
(async () => { | ||
let substream = demux.stream('hello'); | ||
for await (let packet of substream) { | ||
receivedHelloPackets.push(packet); | ||
} | ||
})(), | ||
(async () => { | ||
let substream = demux.stream('abc'); | ||
for await (let packet of substream) { | ||
receivedAbcPackets.push(packet); | ||
} | ||
})() | ||
]); | ||
assert.equal(receivedHelloPackets.length, 10); | ||
assert.equal(receivedAbcPackets.length, 10); | ||
}); | ||
it('should support the stream.once() method', async () => { | ||
@@ -112,0 +144,0 @@ (async () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9445
192