Skip to content

Instantly share code, notes, and snippets.

@FotoVerite
Created June 30, 2013 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FotoVerite/5896595 to your computer and use it in GitHub Desktop.
Save FotoVerite/5896595 to your computer and use it in GitHub Desktop.
Stream Adventure Solution to Concat
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