Followup to a solution to reading a file line by line, as described here: https://stackoverflow.com/a/16013228/570796
var fs = require('fs'),
readline = require('readline'),
instream = fs.createReadStream('/path/to/file');
var rl = readline.createInterface(
{
input: instream,
terminal: false
});
rl.on('line', function(line)
{
console.log(line);
// if(instream.isEnd()) ...
});
How do I detect if I reached the end of the file?
I understand that there is an event on the ReadStream
on('end', () => {/*...*/})
But I need a solution where I can check it through an if statement.