Created
May 9, 2019 20:07
-
-
Save seldo/90acf67dda6db453a5e19fa93a707f80 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
const fs = require('fs'); | |
const readline = require('readline'); | |
async function processLineByLine() { | |
const fileStream = fs.createReadStream('input.txt'); | |
const rl = readline.createInterface({ | |
input: fileStream, | |
crlfDelay: Infinity | |
}); | |
// Note: we use the crlfDelay option to recognize all instances of CR LF | |
// ('\r\n') in input.txt as a single line break. | |
for await (const line of rl) { | |
// Each line in input.txt will be successively available here as `line`. | |
console.log(`Line from file: ${line}`); | |
} | |
} | |
processLineByLine(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment