Skip to content

commenthol/streamss-fork

Repository files navigation

streamss-fork

Fork stream2 into several streams

NPM version Build Status

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...

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:

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.

About

Fork stream2 into several streams

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published