Skip to content

Instantly share code, notes, and snippets.

@you21979
Created April 18, 2016 09:40
Show Gist options
  • Save you21979/c7028e1b387b2dcdf8ed3f9bc02e4a5d to your computer and use it in GitHub Desktop.
Save you21979/c7028e1b387b2dcdf8ed3f9bc02e4a5d to your computer and use it in GitHub Desktop.
'use strict'
const pipe_initialize = (ctx) => {
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
if (chunk == "") { return ;}
var lines = chunk.split("\n");
lines[0] = ctx.fragment + lines[0];
ctx.fragment = lines.pop();
lines.forEach(function(line){
ctx.pipe(line);
});
});
process.stdin.on('end', function(){
});
}
const main = (argv) => {
let ctx = {
fragment : "",
pipe : (line) => {console.log(line)}
}
pipe_initialize(ctx);
}
main(process.argv.slice(2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment