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.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 () => {

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