Created
May 2, 2018 12:55
-
-
Save emilioriosvz/6fc509116772e897bf6ae5548f941a9e to your computer and use it in GitHub Desktop.
readline sample
This file contains hidden or 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
var rl = readline.createInterface({ | |
input: fs.createReadStream(filePath), | |
crlfDelay: Infinity | |
}) | |
rl.on('line', async (line) => { | |
counter += 1 | |
rl.pause() | |
// some async code | |
rl.resume() | |
}) | |
rl.on('close', () => { | |
// some task on close | |
}) | |
rl.on('error', error => console.error(error)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment