4.1.0 • Published 3 years ago

multistream v4.1.0

Weekly downloads
443,682
License
MIT
Repository
github
Last release
3 years ago

multistream travis npm downloads javascript style guide

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

Sauce Test Status

cat

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.

install

npm install multistream

usage

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

contributors

license

MIT. Copyright (c) Feross Aboukhadijeh.

tracemaster-builderwebtorrent-jalihoserver-frameworkwebtorrent-forkbot_megabotwa_zap2emuloadbannerbot-servicessr-react-core@solvencino/fs-stream@infinitebrahmanuniverse/nolb-multisarbundles-esmfiles_as_streamwebtorrent-fix@everything-registry/sub-chunk-2219ti-jsforce-without-refresh@fullstax/pkgxbinxzons-apiunshorten-pinboard-urls@goodforonefare/react-htmltop-video-generatorun-gttsunitestvideostreamssweighwebtorrent-ritwebtorrent-rozzlewebtorrent_bgwhatsapp-bot-pack@kartotherian/cassandrafallback-streamfast-node-downloaderfarrow-reactfetch-video@liudonghua123/pkg@liongard/pkgfederated-search@lakutata-component/datastore@hlolli/arbundles@hosoft/restful-api-framework@homerjam/build-utilsglob-filestreamglue-streams@morgs32/build-utils@nztgdev/jsforce@mikojs/react-ssrgemeindeverzeichnis@naze/plugingasket@nice-digital/file-diff-generatorgenie-drs@leafac/pkg@jsforce/jsforce-nodeimage-organizer@safecoin/arbundlesgttsgtts-mleasy-file-uploader-server@jakzo/pkg@j0nnyboi/arbundlesenergyhub-eventsemojizer@ijjk/now-build-utilsengel-pkg-fork@jesec/pkghotbreak@openziti/ziti-browzer-core@openziti/ziti-sdk-jsgulp-bower-exports@purelightpower/jsforcegulp-prettybellygulp-npm-exports@phated/pkg@smartsheet-bridge/extension-scripts@senojs/pkg@shopify/react-html@souls/pkgjsforce-microjsforce-propeljsforce2@fitbit/sdkjsforcejsforce-fork@scottworks/nexe@skeymeulen/pkg@salto-io/jsforce@tootallnate/build-utilskickboard@trifoia/canvas-data-cli@triply/rattkartotherian-cassandra@subhamkumarsadhukhan/node-gtts@tikaj/pkgbetter-node-gttsblob-log.js@bjrmatos/pkg@bulentv/pkg@bud-tools/jsbt@bud-tools/jsbtools
4.1.0

3 years ago

4.0.1

4 years ago

4.0.0

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.1.1

6 years ago

2.1.0

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.6.1

9 years ago

1.6.0

9 years ago

1.5.2

9 years ago

1.5.1

9 years ago

1.5.0

9 years ago

1.4.3

9 years ago

1.4.2

10 years ago

1.4.1

10 years ago

1.4.0

10 years ago

1.3.0

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago