stream-switch
Stream condition for switch/case
Last updated 10 years ago by popomore .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install stream-switch 
SYNC missed versions from official npm registry.

stream-switch Build Status Coverage Status

Stream condition for switch/case, just like ternary-stream for if/else


Install

$ npm install stream-switch -g

Usage

var switchStream = require('stream-switch');

process.in
.pipe(switchStream(function(buf) {
  if (buf > 0) {
    return 'case1';
  } else if (buf < 0) {
    return 'case2'
  }
}, {
  'case1': streamA,
  'case2': streamB
}))
.pipe(process.stdout)

If buf great than 0, then pipe to streamA. If buf less than 0, then pipe to streamB. Otherwise buf equal to 0, pipe to output directly.

API

switchStream(switch, cases)

switch

Switch condition determine which case will be choose.

Switch can be any type, if switch is function, it will be called.

cases

Choose which stream will be piped to by key switch return.

LISENCE

Copyright (c) 2014 popomore. Licensed under the MIT license.

Current Tags

  • 0.1.1                                ...           latest (10 years ago)

2 Versions

  • 0.1.1                                ...           10 years ago
  • 0.1.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (4)
Dependents (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE