Open masalinas opened 6 years ago
Up ! Agree that would be super useful, because there is currently no way to known when the end of file has been reached
I found a way by wrapping into a promise and declare a global variable that you can increment. Code is bellow (ts).
let maxLines: number = 0
return new Promise((resolve, reject) => {
rl.on('line', (line, lineCount, byteCount) => {
maxLines = lineCount
// here i am looking for a string, and...
// ... if blahbla => resolve promise
})
.on('end', () => {
console.log('End of file reached', maxLines)
})
.on('error', (err) => {
reject(err)
})
})
How can I get the number of lines of the file with your library?