Created
October 5, 2013 19:45
-
-
Save aaronj1335/6845312 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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