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 1,000,000+ packages pre-installed, including add-stream with all npm packages installed. Try it out:

var addStream = require("add-stream")

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

add-stream v1.0.0

Append the contents of one stream onto another.

add-stream Build Status

Append the contents of one stream onto another.


var fs = require('fs');
var es = require('event-stream');
var addStream = require('add-stream');

// Append strings/buffers
fs.createReadStream('1.txt') // 1.txt contains: number1
    .pipe(addStream(fs.createReadStream('2.txt'))) // 2.txt contains: number2
    .pipe(fs.createWriteStream('appended.txt')); // appended.txt contains: number1number2

// Append object streams
es.readArray([1, 2, 3])
    .pipe(addStream.obj(es.readArray([4, 5, 6])))
    .pipe(es.writeArray(function (err, array) {
        console.log(array); // [ 1, 2, 3, 4, 5, 6 ]


var transformStream = addStream(stream, opts = {})

Create a transform stream that appends the contents of stream onto whatever is piped into it. Options are passed to the transform stream's constructor.

var transformStream = addStream.obj(stream, opts = {})

A convenient shortcut for addStream(stream, {objectMode: true}).



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