conditional-stream

A duplex stream that only passes data through when a set function returns true

npm install conditional-stream
1 downloads in the last week
4 downloads in the last month

conditional-stream

conditional-stream is a duplex stream that only passes data when a set function returns true

requirements

install

  • npm install conditional-stream

example

to filter/limit a stream to only numbers

onlyNumbers.js

var CondStream = require('conditional-stream')
  , cond = new CondStream(function(input) {
  return (!isNaN(Number(input.toString())))
})

process.stdin.pipe(cond).pipe(process.stdout)

console

> echo 2 | node onlyNumbers.js
2

> echo a | node onlyNumbers.js
>

license

MIT

npm loves you