combined-stream

Here is a simple example that shows how you can use combined-stream to combine
two files into one:

var CombinedStream =require('combined-stream');

var fs =require('fs');

var combinedStream = CombinedStream.create();

combinedStream.append(fs.createReadStream('file1.txt'));

combinedStream.append(fs.createReadStream('file2.txt'));

combinedStream.pipe(fs.createWriteStream('combined.txt'));

While the example above works great, it will pause all source streams until
they are needed. If you don't want that to happen, you can set pauseStreams
to false:

var CombinedStream =require('combined-stream');

var fs =require('fs');

var combinedStream = CombinedStream.create({pauseStreams:false});

combinedStream.append(fs.createReadStream('file1.txt'));

combinedStream.append(fs.createReadStream('file2.txt'));

combinedStream.pipe(fs.createWriteStream('combined.txt'));

However, what if you don't have all the source streams yet, or you don't want
to allocate the resources (file descriptors, memory, etc.) for them right away?
Well, in that case you can simply provide a callback that supplies the stream
by calling a next() function:

Whether to apply back pressure to the underlaying streams. If set to false,
the underlaying streams will never be paused. If set to true, the
underlaying streams will be paused right after being appended, as well as when
delayedStream.pipe() wants to throttle.

If combinedStream.pauseStreams is set to false, this does nothing.
Otherwise a 'pause' event is emitted, this goes to the stream that is
currently being drained, so you can use it to apply back pressure.