Create a writable stream that writes to multiple other writeable streams
npm install multi-write-stream
var multi = require('multi-write-stream')
var fs = require('fs')
var stream = multi([
fs.createWriteStream('file-1'),
fs.createWriteStream('file-2')
])
stream.write('hello')
stream.write('world')
stream.end(function () {
// both file-1 and file-2 now contains 'helloworld'
})
Create a new multi write stream. Options are forwarded to the stream constructor. Other options include
{
autoDestroy: true // destroy the stream if a child stream errors
}
Same as above but sets objectMode = true
Add a stream after instantiating the multi writer
Remove a stream after instantiating the multi writer
MIT