Created
June 30, 2013 19:48
-
-
Save FotoVerite/5896595 to your computer and use it in GitHub Desktop.
Stream Adventure Solution to Concat
This file contains 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 stream = require('stream'); | |
var liner = new stream.Transform( { objectMode: true } ); | |
liner._buffer = ''; | |
liner._transform = function (chunk, encoding, done) { | |
var self = this; | |
var data = chunk.toString(); | |
this._buffer = this._buffer + data | |
done(); | |
}; | |
liner._flush = function (done) { | |
this._buffer = this._buffer.split("").reverse().join("") | |
this.push(this._buffer) | |
this.push('\n' + "") | |
done(); | |
}; | |
process.stdin.pipe(liner).pipe(process.stdout); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment