Package Exports
- multistream
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (multistream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
multistream

A stream that emits multiple other streams one after another (streams2)

Simple, robust streams2 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.
install
npm install multistreamusage
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')
]
MultiStream(streams).pipe(process.stdout) // => 123To 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')
}
]
MultiStream(streams).pipe(process.stdout) // => 123Alternativelly, streams may be created by an asyncronous "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)
}
MultiStream(factory).pipe(process.stdout) // => 123contributors
license
MIT. Copyright (c) Feross Aboukhadijeh.