Last active
August 28, 2019 07:57
-
-
Save keksipurkki/037eb485542b1de46faa150a0c82f95e to your computer and use it in GitHub Desktop.
Process STDIN line by line
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
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