Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including merge-stream with all npm packages installed. Try it out:

var mergeStream = require("merge-stream")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

merge-stream v1.0.1

Create a stream that emits events from multiple other streams


Merge (interleave) a bunch of streams.

build status


var stream1 = new Stream();
var stream2 = new Stream();

var merged = mergeStream(stream1, stream2);

var stream3 = new Stream();
//=> false


This is adapted from event-stream separated into a new module, using Streams3.



Type: function

Merges an arbitrary number of streams. Returns a merged stream.


A method to dynamically add more sources to the stream. The argument supplied to add can be either a source or an array of sources.


A method that tells you if the merged stream is empty.

When a stream is "empty" (aka. no sources were added), it could not be returned to a gulp task.

So, we could do something like this:

stream = require('merge-stream')();
// Something like a loop to add some streams to the merge stream
// stream.add(streamA);
// stream.add(streamB);
return stream.isEmpty() ? null : stream;




RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free