Package Exports
- thru
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (thru) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
thru
minimalist transform stream implementation
why
sugar for stream.Transform
how
var thru = require('thru');
var input = thru();
var inflate = thru(function(obj, cb) {
if (obj === 'a') {
this.push('a');
this.push('b');
cb();
} else {
cb(null, obj);
}
});
var modify = thru(function(obj, cb) {
if (obj === 'd') obj = 'c';
cb(null, obj);
});
var deflate = thru(function(obj, cb) {
if (obj === 'e') cb();
else cb(null, obj);
});
var newlines = thru(function(obj, cb) {
cb(null, obj + '\n');
});
input
.pipe(inflate)
.pipe(modify)
.pipe(deflate)
.pipe(newlines)
.pipe(process.stdout);
newlines.on('end', function() {
console.log('done!');
});
input.write('a'); // a
// b
input.write('d'); // c
input.write('e');
input.end(); // done!
inspiration
license
WTFPL