package
A stream filter for node, to create pipable filters for arbitary streams.
npm install filterGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
/ () | |_ ___ _ __
| || | | / _ \ '|
| | | | || __/ |
|| |||____|_|
var Filter = require('filter');
/*
// Just emit a data event to pass the data on. this.emit('data', data); });
/*
my_filter.write = function (data) { data = data.replace('foo', 'bar');
// Just emit a data event to pass the data on. this.emit('data', data); };
/*
var CoffeeFilter = function () { this.replace = 'coffee'; this.with = 'water';
// Make sure to call the Filter constructor. Filter.call(this); };
// Inherit methods. util.inherits(CoffeeFilter, Filter);
// Then overwrite the write method. CoffeeFilter.prototype.write = function (data) { data = data.replace(this.replace, this.with);
this.emit('data', data); };
// Create a instance var coffee_filter = new CoffeeFilter;
/**
var read_stream = fs.createReadStream('/home/guy/java.txt'), write_stream = fs.createWriteStream('/home/guy/node.txt');
var filter = new Filter(function (data) { this.emit('data', data.replace(/java/gi, 'node')); });
read_stream.setEncoding('utf8');
read_stream.pipe(filter); filter.pipe(write_stream);