node-readlines-next is a fork of
node-readlines! A package developed by Yoan Arnaudov! Original Repo here
The author wasn't active for 2 years up to now!
I took the deliberate to Fork it! Merged one PR (One bring better performance) [check here]! And added typescript declarations!
Also if any PR are send! I'll make sure to treat them!
Original author description
Reading file line by line may seem like a trivial problem, but in node, there is no straightforward way to do it. There are a lot of libraries using Transform Streams to achieve it, but it seems like a overkill, so I've wrote simple version using only the
filesystem module of node. Note that this is synchronous library.
npm install n-readlines-next
new readlines(filename, [options]);
new readlines(fd, [options]);
filename- String path to the file you want to read from
fd- File descriptor
readChunk- Integer number of bytes to read at once. Default: 1024
newLineCharacter- String new line character, only works with one byte characters for now. Default:
node-readlines can handle files without newLineCharacter after the last line
buffer with the line data without the
false if end of file is reached.
Resets the pointer and starts from the beginning of the file. This works only if the end is not reached.
var ReadLines = ;var liner = './textFile.txt';var line;var lineNumber = 0;while line = linernextconsole;lineNumber++;console;
For imports and types