through2-filter / 1.4.0 last updated 5 months ago created on Aug 6th 2013
Install
npm install --save through2-filter
Clone
git clone git@github.com:brycebaril/through2-filter.git
dependencies
show all 7
| main |
|
through2 | 0.5.1 | MIT |
|
|
xtend | 3.0.0 | MIT |
maintainers
bryce
versions
8 total
| 1.4.0 | 5 months ago | bryce |
| 1.3.1 | 10 months ago | bryce |
| 1.3.0 | a year ago | bryce |
| 1.2.0 | a year ago | bryce |
| 1.1.0 | a year ago | bryce |
| 1.0.2 | a year ago | bryce |
| 1.0.1 | a year ago | bryce |
| 1.0.0 | a year ago | bryce |
readme
through2-filter
This is a super thin wrapper around through2 that works like Array.prototype.filter but for streams.
For when through2 is just too verbose :wink:
Note you will NOT be able to alter the content of the chunks. This is intended for filtering only. If you want to modify the stream content, use either through2 or through2-map.
*Differences from Array.prototype.filter:
- No third
arraycallback argument. That would require realizing the entire stream, which is generally counter-productive to stream operations. Array.prototype.filterdoesn't modify the source Array, which is somewhat nonsensical when applied to streams.
API
require("through2-filter")([options], fn)
Create a through2-filter instance that will call fn(chunk). If fn(chunk) returns "true" the chunk will be passed downstream. Otherwise it will be dropped.
require("through2-filter").ctor([options], fn)
Create a through2-filter Type that can be instantiated via new Type() or Type() to create reusable spies.
require("through2-filter").obj([options], fn)
Create a through2-filter that defaults to objectMode = true.
require("through2-filter").objCtor([options], fn)
Create a through2-filter Type that defaults to objectMode = true.
Options
- wantStrings: Automatically call chunk.toString() for the super lazy.
- all other through2 options
LICENSE
MIT
