
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
multistream
Advanced tools

Simple, robust streams3 version of combined-stream. Allows you to combine multiple streams into a single stream. When the first stream ends, the next one starts, and so on, until all streams are consumed.
This module is used by WebTorrent, specifically create-torrent.
npm install multistream
Use multistream like this:
var MultiStream = require('multistream')
var fs = require('fs')
var streams = [
fs.createReadStream(__dirname + '/numbers/1.txt'),
fs.createReadStream(__dirname + '/numbers/2.txt'),
fs.createReadStream(__dirname + '/numbers/3.txt')
]
new MultiStream(streams).pipe(process.stdout) // => 123
You can also create an object-mode stream with MultiStream.obj(streams).
To lazily create the streams, wrap them in a function:
var streams = [
fs.createReadStream(__dirname + '/numbers/1.txt'),
function () { // will be executed when the stream is active
return fs.createReadStream(__dirname + '/numbers/2.txt')
},
function () { // same
return fs.createReadStream(__dirname + '/numbers/3.txt')
}
]
new MultiStream(streams).pipe(process.stdout) // => 123
Alternatively, streams may be created by an asynchronous "factory" function:
var count = 0
function factory (cb) {
if (count > 3) return cb(null, null)
count++
setTimeout(function () {
cb(null, fs.createReadStream(__dirname + '/numbers/' + count + '.txt'))
}, 100)
}
new MultiStream(factory).pipe(process.stdout) // => 123
MIT. Copyright (c) Feross Aboukhadijeh.
The 'concat-stream' package is used to concatenate multiple streams into a single buffer or string. Unlike 'multistream', which can handle multiple streams sequentially, 'concat-stream' is more focused on collecting all data into a single output at once. It is useful for scenarios where you need the entire data set available at once rather than streaming it.
The 'stream-combiner' package allows you to combine multiple streams into a single pipeline. It is similar to 'multistream' in that it can handle multiple streams, but it is more focused on creating a pipeline of streams that process data in sequence. This can be useful for tasks like transforming data through multiple stages.
The 'merge-stream' package allows you to merge multiple streams into a single stream. Unlike 'multistream', which concatenates streams sequentially, 'merge-stream' interleaves the data from multiple streams. This can be useful for scenarios where you need to handle data from multiple sources simultaneously.
FAQs
A stream that emits multiple other streams one after another (streams3)
The npm package multistream receives a total of 1,719,219 weekly downloads. As such, multistream popularity was classified as popular.
We found that multistream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.