min-filter.js
Minimal filter chain for Node.js and the browser
Install with npm
npm install min-filter
Usage
The filter operates on a min-iterator implementation. This example uses a live-list to demonstrate the usage:
var filter = ;var List = List; var l = ;l;l; var it = l; ;
API
filter(iterator[, scope][[, then], callback])
iterator
: min-iterator that returns objects with filter functionsscope
: The object to use asthis
in each filter function, if not specified otherwisethen
: A function that is invoked after the last filter callednext
. Receives an optional callback argument. If a callback is given, it triggers execution of the functions passed tonext
by the filters.callback
: A function that is invoked after all processing of all filters, the done function and all callbacks has finished. Receives an error object as the first argument and any additional arguments passed back by the callbacks.
Data structure of objects returns by iterator:
fn
: The filter functionscope
: The scope to use when invoking the filter function. This overrides the scope passed tofilter
.
Valid argument combinations:
filter(it, callback)
: Invokes filters, thencallback
filter(it, then, callback)
: Invokes filters, callsthen
after last filter callednext
, then invokescallback
filter(it, scope, callback)
: Invokes filters with given scope, then invokescallback
filter(it, scope, then, callback)
: Invokes filters with given scope, callsthen
after last filter callednext
, then invokescallback
Browser compatibility
To use this module in a browser, download the npm package and then use Browserify to create a standalone version.
License
MIT