Created
April 18, 2016 09:40
-
-
Save you21979/c7028e1b387b2dcdf8ed3f9bc02e4a5d to your computer and use it in GitHub Desktop.
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
'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