Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mafintosh/multi-write-stream
Create a writable stream that writes to multiple other writeable streams
https://github.com/mafintosh/multi-write-stream
Last synced: 17 days ago
JSON representation
Create a writable stream that writes to multiple other writeable streams
- Host: GitHub
- URL: https://github.com/mafintosh/multi-write-stream
- Owner: mafintosh
- License: mit
- Created: 2015-07-15T16:45:01.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-22T19:32:05.000Z (over 6 years ago)
- Last Synced: 2024-10-16T23:40:42.535Z (23 days ago)
- Language: JavaScript
- Size: 131 KB
- Stars: 30
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nodejs - multi-write-stream - Create a writable stream that writes to multiple other writeable streams. (Repository / Streams)
- awesome-nodejs-streams - mafintosh/multi-write-stream - Create a writable stream that writes to multiple other writeable streams (Modules)
README
# multi-write-stream
Create a writable stream that writes to multiple other writeable streams
```
npm install multi-write-stream
```[![build status](http://img.shields.io/travis/mafintosh/multi-write-stream.svg?style=flat)](http://travis-ci.org/mafintosh/multi-write-stream)
## Usage
``` js
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'
})
```## API
#### `stream = multi(arrayOfWritableStreams, [options])`
Create a new multi write stream. Options are forwarded to the
stream constructor. Other options include``` js
{
autoDestroy: true // destroy the stream if a child stream errors
}
```#### `objStream = multi.obj(arrayOfWritableStreams, [options])`
Same as above but sets `objectMode = true`
#### `stream.add(otherStream)`
Add a stream after instantiating the multi writer
#### `stream.remove(otherStream)`
Remove a stream after instantiating the multi writer
## License
MIT