Filter stream data
JavaScript
Switch branches/tags
Latest commit f35c9d8 Sep 2, 2016 @parshap 2.1.0
Permalink
Failed to load latest commit information.
.gitignore Add tests Aug 9, 2013
.travis.yml Travis CI file, prepublish test hook Aug 15, 2016
README.md Improve readme Sep 2, 2016
index.js
package.json 2.1.0 Sep 2, 2016
test.js Style Sep 2, 2016

README.md

stream-filter

Filter data using a through stream.

build status

Installation

npm: stream-filter

npm install stream-filter

Example

var filter = require("stream-filter");

process.stdin.pipe(filter(function(data) {
	return data.length > 2;
})).pipe(process.stdout);

Async Filter Function

var filter = require("stream-filter");

process.stdin.pipe(filter.async(function(data, callback) {
	doAsyncThing(data, function(err, size) {
		callback(err, size > 2);
	});
})).pipe(process.stdout);

API

var filter = require("stream-filter");
filter(fn, options);
filter.obj(fn, options);
filter.async(fn, options);
filter.async.obj(fn, options);

Note that filter.obj(fn) and filter.async.obj(fn) are convenience wrappers to pass { objectMode: true }.

See index.js and test.js for API details.