Skip to content

Instantly share code, notes, and snippets.

@leepowelldev
Created January 20, 2014 10:32
Show Gist options
  • Save leepowelldev/8517992 to your computer and use it in GitHub Desktop.
Save leepowelldev/8517992 to your computer and use it in GitHub Desktop.
var stream = require('stream');
GreenStream.prototype = Object.create(stream.Writable.prototype, {
constructor: { value: GreenStream }
});
function GreenStream(options) {
stream.Writable.call(this, options);
}
GreenStream.prototype._write = function(chunk, encoding, callback) {
process.stdout.write('\u001b[32m' + chunk + '\u001b[39m');
callback();
};
process.stdin.pipe(new GreenStream());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment