I\'m looking to process a text file with node using a command line call like:
node app.js < input.txt
Each line of the file needs to be proce
readline
is specifically designed to work with terminal (that is process.stdin.isTTY === true
). There are a lot of modules which provide split functionality for generic streams, like split. It makes things super-easy:
process.stdin.pipe(require('split')()).on('data', processLine)
function processLine (line) {
console.log(line + '!')
}