Simple streaming readline module.
Read a file line by line.
npm install linebyline
npm install .npm test
Simple streaming readline module for NodeJS. Reads a file and buffers new lines emitting a line event for each line.
var readline = require'linebyline'rl = readline'./somefile.txt';rlon'line'// do something with the line of texton'error'// something went wrong;
As the underlying
fs.createReadStream doesn't care about the specific ASCII encoding of the file, an alternative way to decode the file is by telling the
readline library to retain buffer and then decoding it using a converter (e.g.
var readline = require'linebyline'rl = readline'./file-in-win1251.txt'retainBuffer: true //tell readline to retain buffer;rlon"line"var line = iconvdecodedata 'win1251';// do something with the line of converted text;
readingObject- file path or stream object
maxLineLength- override the default 4K buffer size (lines longer than this will not be read)
retainBuffer- avoid converting to String prior to emitting 'line' event; will pass raw buffer with encoded data to the callback
BSD © Craig Brookes