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

2

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

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

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

### Consuming using async loops
```js

@@ -41,3 +43,6 @@ let demux = new StreamDemux();

// the same time.
let asyncIterator = demux.stream('def').getAsyncIterator();
// Note that you can optionally pass a number n to the
// createAsyncIterator(n) method to force the iteration to
// timeout after n milliseconds of innactivity.s
let asyncIterator = demux.stream('def').createAsyncIterator();
while (true) {

@@ -70,2 +75,26 @@ let packet = await asyncIterator.next();

### Consuming using the once method
```js
// Log the next received packet from the abc stream.
(async () => {
// The returned promise never times out.
let packet = await demux.stream('abc').once();
console.log('Packet:', packet);
})();
// Same as above, except with a timeout of 10 seconds.
(async () => {
try {
let packet = await demux.stream('abc').once(10000);
console.log('Packet:', packet);
} catch (err) {
// If no packets are written to the 'abc' stream before
// the timeout, an error will be thrown and handled here.
// The err.name property will be 'TimeoutError'.
console.log('Error:', err);
}
})();
```
## Goal

@@ -72,0 +101,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