Node 'readline' module does not have an 'end' event - how can I do something when there are no more lines?

mikemaccana picture mikemaccana · Apr 7, 2014 · Viewed 14k times · Source

Reading the official docs for the readline module, there is no end event like other streams. Trying

reader.on('end', cb);

Doesn't work.

How can I run a callback once there are no more lines to be read?

Answer

mikemaccana picture mikemaccana · Apr 7, 2014

Nevermind, it's close.

reader.on('close', cb);