node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »

parallel-multistream

parallel-multistream

Parallel version of multistream

npm install parallel-multistream

build status

Usage

var parallel = require('parallel-multistream')
 
var stream = parallel([stream1, stream2, stream3])
 
stream.on('data', function(data) {
  // 1st: data will be from stream1 
  // 2nd: data will be from stream2 
  // 3rd: data will be from stream3 
  // 4th: data will be from stream1 
  // ... 
})
 
stream.on('end', function() {
  // all streams have ended 
})

Use stream.destroy() to all sub-streams and emit close.

If you want to add an additional stream you can call stream.add(substream).

License

MIT