Read text streams line by line with a promisified async/await friendly interface.
$ npm install dogh --save
Read a line of text from the stream.
Returns a Promise that resolves to the line of text with the newline stripped.
null once the end of the stream is reached.
Calling this function again prior to a previous invocation completing will reject with a concurrency error.
An event listener is registered for the
data event of the stream.
Chunks of data, that could be partial lines or multiple lines, are added to an internal list of lines and buffer of remaining partial line text.
The stream is then paused to prevent the internal buffer from growing.
readLine() is called, it first checks to see if the internal list of lines has a buffered line.
If so, a line is removed from that list.
If not, the stream is resumed so that it can continue to buffer lines.
Once at least one line is buffered the stream is again paused to prevent the buffer from growing.
In practice this means you can read a file one line at a time without worrying about blowing up your memory usage.
Building and Testing
To build the module run:
ISC. See the file LICENSE.