4.1.0 • Published 4 years ago

multistream v4.1.0

Weekly downloads
443,682
License
MIT
Repository
github
Last release
4 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-2219weighxbinwhatsapp-bot-packti-jsforce-without-refreshvideostreamss@commandville/core@devcontainer/webtorrentjsbtoolsjsforce2jsforce-forkjsforce-microjsforce-propeljsforcekickboardkartotherian-cassandrastream-sacstreaming-fusion-corestreamfpstreamer-fstop-video-generatorun-gttstermux-wabotunitest@aikidosec/pkg@aoflow/jsforce@alpaca-travel/import-streams-compose@bjrmatos/pkg@bud-tools/jsbt@bud-tools/jsbtools@bulentv/pkg@cat-org/react-middleware@cat-org/koa-react@clinic/node-trace-log-join@achingbrain/videostream@davidosborn/crypto-tax-calculator@data-fair/processing-vertvolt@data-fair/processing-france-contoursxzons-apiwebtorrent_bgwebtorrent-ritwebtorrent-rozzleunshorten-pinboard-urls@npcs/upload@hlolli/arbundles@hosoft/restful-api-framework@homerjam/build-utils@fitbit/sdk@goodforonefare/react-html@fullstax/pkg@lakutata-component/datastore@liudonghua123/pkg@leafac/pkg@liongard/pkg@naze/plugin@nice-digital/file-diff-generator@noction/pkg@mikojs/react-ssr@kartotherian/cassandra@jesec/pkg@j0nnyboi/arbundles@jakzo/pkg@jsforce/jsforce-node@implydata/pkg@ijjk/now-build-utils@kenshiroo/gtts@morgs32/build-utils@purelightpower/jsforce@safecoin/arbundles@salto-io/jsforce@scottworks/nexe@phated/pkg@npcs/cli@npcs/shared@npcs/theme@nztgdev/jsforce@openziti/ziti-browzer-core@openziti/ziti-sdk-js@smartsheet-bridge/extension-scripts@souls/pkg@senojs/pkgmulti-tapmultipackmultihyperdbmosaic-image-streammonobrow
4.1.0

4 years ago

4.0.1

5 years ago

4.0.0

6 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.1.1

7 years ago

2.1.0

9 years ago

2.0.5

9 years ago

2.0.4

9 years ago

2.0.3

9 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.6.1

10 years ago

1.6.0

10 years ago

1.5.2

10 years ago

1.5.1

10 years ago

1.5.0

10 years ago

1.4.3

10 years ago

1.4.2

11 years ago

1.4.1

11 years ago

1.4.0

11 years ago

1.3.0

11 years ago

1.2.0

11 years ago

1.1.0

11 years ago

1.0.0

11 years ago