Skip to content

Instantly share code, notes, and snippets.

@emilioriosvz
Created May 2, 2018 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emilioriosvz/6fc509116772e897bf6ae5548f941a9e to your computer and use it in GitHub Desktop.
Save emilioriosvz/6fc509116772e897bf6ae5548f941a9e to your computer and use it in GitHub Desktop.
readline sample
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