conditional-stream
v1.0.0
Published
A duplex stream that only passes data through when a set function returns true
Downloads
1
Maintainers
Readme
conditional-stream
conditional-stream is a duplex stream that only passes data when a set function returns true
requirements
- node v0.10+ (this uses streams2)
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