Stream condition for switch/case


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

$ npm install stream-switch -g

var switchStream = require('stream-switch');
.pipe(switchStream(function(buf) {
  if (buf > 0) {
    return 'case1';
  } else if (buf < 0) {
    return 'case2'
}, {
  'case1': streamA,
  'case2': streamB

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.

switchStream(switch, cases)

Switch condition determine which case will be choose.

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

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

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