BcnFilter is an iterator that provides a way to filter and simplify iterators.
npm install bcn-filter
var filter = new BcnFilter(iterator, filterFunction);
var asyncFilter = new BcnFilter(iterator, asycFilterFunction, {async: true});
filterFunction(key, value) -> [key, value] | null (ignore value) asyncFilterFunction(key, value, cb) -> cb([key, value]) | cb(null) (ignore value)
You can use this to rewrite streams by ignoring certain elements or transforming values on the fly.
Filter function that does nothing
function filterNone(key, value) {
return [key, value];
}
Filter some elements
function filterJustGood(key, value) {
return value.isGood ? [key, value] : null;
}
Pauses iterator
Resumes iterator
outputs the filtered value
emitted when finished