switch-stream
swap out a stream in-place
example
For the first three lines, this stream uppercases its input with the prelude
transform, then it switches to the size
transform, which prints the length of
each line.
var switcher = ;var split = ;var through = ;var lines = 0;var prelude =;var size =;var sw = ;processstdin;
output:
$ echo -e 'one\ntwo\nthree\nfour\nfive\nsix\nseven' | node example/switch.js
ONE
TWO
THREE
4
4
3
5
0
methods
var switcher =
var sw = switcher(initial)
Create a new switch stream sw
with an optional initial
stream to start with.
Input written to sw
will be passed to the currently active stream and output
from initial
will be output on sw
.
sw.set(stream)
Set a new stream for sw
to pass data to and from.
install
With npm do:
npm install switch-stream
license
MIT