2.0.0 • Published 8 years ago

stream-police v2.0.0

Weekly downloads
11
License
MIT
Repository
github
Last release
8 years ago

stream-police

Build Status npm install npm version js-standard-style License

Filter your streams.

usage

streamPolice(validateFunction[, streamOptions]) -> DuplexStream

  • For every chunk of data written to DuplexStream, it will be passed to validateFunction which is expected to return a boolean value indicating whether the value should be emitted or not.
  • streamOptions is an optional argument that will be passed to instantiate DuplexStream

example

var police = require('stream-police')

var stream = police(isNaN)

stream.write('5') // stream emits nothing
stream.write('!') // stream emits '!'

or:

var police = require('stream-police')

var stream = police(hasCat, {objectMode: true})

function hasCat (obj) {
  return obj.hasOwnProperty('cat')
}

stream.write({dog: 'woof'}) // stream emits nothing
stream.write({cat: 'meow'}) // stream emits {cat: 'meow'}

license

MIT

2.0.0

8 years ago

1.0.0

9 years ago

0.0.5

10 years ago

0.0.3

10 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago