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.0 to 3.0.1

2

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

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

@@ -36,2 +36,16 @@ # stream-demux

(async () => {
// 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.
let asyncIterator = demux.stream('def').getAsyncIterator();
while (true) {
let packet = await asyncIterator.next();
if (packet.done) break;
console.log('DEF (while loop):', packet.value);
}
})();
(async () => {
for (let i = 0; i < 10; i++) {

@@ -38,0 +52,0 @@ await wait(10);

@@ -110,2 +110,28 @@ const assert = require('assert');

it('should support iterating over a substream using a while loop', async () => {
(async () => {
for (let i = 0; i < 10; i++) {
await wait(10);
demux.write('hello', 'world' + i);
demux.write('hello', 'foo' + i);
}
demux.end('hello');
})();
let receivedPackets = [];
let asyncIterator = demux.stream('hello').createAsyncIterator();
while (true) {
let packet = await asyncIterator.next();
if (packet.done) break;
receivedPackets.push(packet.value);
}
assert.equal(receivedPackets.length, 20);
assert.equal(receivedPackets[0], 'world0');
assert.equal(receivedPackets[1], 'foo0');
assert.equal(receivedPackets[2], 'world1');
assert.equal(receivedPackets[3], 'foo1');
});
it('should support ending all streams using a single endAll command', async () => {

@@ -112,0 +138,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