Skip to content

Instantly share code, notes, and snippets.

@keksipurkki
Last active August 28, 2019 07:57
Show Gist options
  • Save keksipurkki/037eb485542b1de46faa150a0c82f95e to your computer and use it in GitHub Desktop.
Save keksipurkki/037eb485542b1de46faa150a0c82f95e to your computer and use it in GitHub Desktop.
Process STDIN line by line
const os = require("os");
async function main() {
let input = Buffer.from([]);
for await (const chunk of process.stdin) {
input = Buffer.concat([input, chunk]);
}
for (const line of input.toString().split(os.EOL)) {
console.log(line);
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment