Skip to content

Instantly share code, notes, and snippets.

@aaronj1335
Created October 5, 2013 19:45
Show Gist options
  • Select an option

  • Save aaronj1335/6845312 to your computer and use it in GitHub Desktop.

Select an option

Save aaronj1335/6845312 to your computer and use it in GitHub Desktop.
var byline = require('byline');
var stream = require('stream');
function MyTransform1() {
stream.Transform.apply(this, arguments);
}
MyTransform1.prototype = stream.Transform.prototype;
MyTransform1.prototype._transform = function(chunk, encoding, done) {
this.push(chunk.toString().toUpperCase());
done();
};
function MyTransform2() {
stream.Transform.apply(this, arguments);
}
MyTransform2.prototype = stream.Transform.prototype;
MyTransform2.prototype._transform = function(chunk, encoding, done) {
this.push(chunk + ' foo');
done();
};
// this should produce upper-case lines w/ lower-case "foo" at the end, but the
// lines aren't uppercase
process.stdin
.pipe(byline.createStream())
.pipe(new MyTransform1())
.pipe(new MyTransform2())
.pipe(process.stdout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment