Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
switch between output streams. e.g. a filter that pipes valid & invalid data to different streams
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
test
.gitignore
.travis.yml
Readme.md
index.js
package.json

Readme.md

switchstream

Change where data flows as it passes through the switchstream.

var Switchstream = require('switchstream')

var switchstream = Switchstream(function(data) {
  // return the key of the stream you want to
  // pipe this data to
  if (data === 'a') return 'stream a'
  if (data === 'b') return 'stream b'
})

from(['a', 'b',  'a', 'a', 'b']) // example data
.pipe(switchstream.between({
  'stream-a': fs.createWriteStream('a.txt'),
  'stream-b': fs.createWriteStream('b.txt')
}))

// result will be a.txt with the three a's and b.txt with the two b's

Licence

MIT

Something went wrong with that request. Please try again.