
Product
Introducing the Alert Details Page: A Better Way to Explore Alerts
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.
multicast-stream
Advanced tools
Create a multicast stream that lets multiple consumers independently read the same data
Create a multicast stream that lets multiple consumers independently read the same data
npm install multicast-stream
Without this package
Using Readable#text() on a stream can only work with a single consumer. If you try to read the stream with multiple consumers, it will be empty as the stream can only be read once.
import {Readable} from 'node:stream';
import {text} from 'node:stream/consumers';
const sourceStream = Readable.from(['Hello', ' ', 'World']);
const [result1, result2] = await Promise.all([text(sourceStream), text(sourceStream)]);
console.log(result1); // 'Hello World'
console.log(result2); // ''
With this package
This package allows multiple consumers to independently read the same data from a single source stream.
import {Readable} from 'node:stream';
import {text} from 'node:stream/consumers';
import multicastStream from 'multicast-stream';
const sourceStream = Readable.from(['Hello', ' ', 'World']);
const createConsumer = multicastStream(sourceStream);
const consumer1 = createConsumer();
const consumer2 = createConsumer();
const [result1, result2] = await Promise.all([text(consumer1), text(consumer2)]);
console.log(result1); // 'Hello World'
console.log(result2); // 'Hello World'
multicastStream(sourceStream)Creates a function that returns independent streams for each consumer.
sourceStream (Readable): The source stream to multicast.() => PassThrough: A function that returns a new PassThrough stream for each consumer.FAQs
Create a multicast stream that lets multiple consumers independently read the same data
The npm package multicast-stream receives a total of 0 weekly downloads. As such, multicast-stream popularity was classified as not popular.
We found that multicast-stream demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.