Socket
Book a DemoInstallSign in
Socket

switchstream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

switchstream

Dynamically update a stream's output destination.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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

Keywords

switch

FAQs

Package last updated on 11 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts