interleave-stream

1.0.2 • Public • Published

interleave-stream

npm js-standard-style

Interleave multiple input streams into a single stream

Will emit chunks from input streams in order, e.g. [s1chunk1, s2chunk1, s3chunk1, s1chunk2, s2chunk2, etc..]. Use split or block-stream2 in order to control chunks from input streams.

Install

npm install -S interleave-stream

Usage

var interleave = require('interleave-stream')
var split = require('split2')
var s1 = split()
var s2 = split()
 
interleave([s1, s2]).pipe(process.stdout)
 
s1.end('1\n2\n3')
s2.end('A\nB\nC')
 
// outputs `1A2B3C` to stdout

API

var interleave = require('interleave-stream')

interleave(streams, opts)

Where:

  • streams is an array of readable streams
  • opts is the same as the options for ReadableStream

Returns a ReadableStream that interleaves chunks from input streams in order.

interleave.obj(streams, opts)

For objectMode streams.

Contribute

PRs accepted.

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © Gregor MacLennan

Package Sidebar

Install

npm i interleave-stream

Weekly Downloads

105

Version

1.0.2

License

MIT

Last publish

Collaborators

  • andrew_chou
  • substack
  • karissa
  • digidem-admin
  • gmaclennan
  • noffle