https://github.com/commenthol/streamss-fork
Fork stream2 into several streams
https://github.com/commenthol/streamss-fork
fork stream2
Last synced: 21 days ago
JSON representation
Fork stream2 into several streams
- Host: GitHub
- URL: https://github.com/commenthol/streamss-fork
- Owner: commenthol
- License: mit
- Created: 2019-11-17T05:45:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-10-10T05:37:55.000Z (over 4 years ago)
- Last Synced: 2025-01-09T11:38:20.456Z (over 1 year ago)
- Topics: fork, stream2
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# streamss-fork
> Fork stream2 into several streams
[](https://www.npmjs.com/package/streamss-fork/)
[](https://travis-ci.org/commenthol/streamss-fork)
Fork a single stream into multiple other streams.
The main stream can be piped as well.
## Install
npm i -S streamss-fork
## Example
**Fork a stream**
Same as `cat package.json | tee one.log two.log` in bash...
```js
const fs = require('fs')
const { fork } = require('streamss-fork')
const one = fs.createWriteStream(`./one.log`)
const two = fs.createWriteStream(`./two.log`)
fs.createReadStream(`./package.json`)
.pipe(fork([one, two]/* ,{ objectMode: false }*/))
.pipe(process.stdout)
```
## Methods
### fork([streams], options)
**Parameters:**
- `{Writable[]} streams` - Array of Writable Streams
- `{Object} [options]` - see [https://nodejs.org/...](https://nodejs.org/dist/latest/docs/api/stream.html#stream_constructor_new_stream_writable_options)
**Return:**
`{Transform}` A Transform stream
## Contribution and License Agreement
If you contribute code to this project, you are implicitly allowing your
code to be distributed under the MIT license. You are also implicitly
verifying that all code is your original work or correctly attributed
with the source of its origin and licence.
## License
Copyright (c) 2019 commenthol (MIT License)
See [LICENSE][] for more info.
[LICENSE]: ./LICENSE
[stream-cat]: https://github.com/micnews/stream-cat
[Readable]: http://nodejs.org/api/stream.html#stream_class_stream_readable
[readable-stream]: https://github.com/isaacs/readable-stream