nacholibre / node-readlines

Read large text files line by line (synchronous) for Node.js
MIT License
161 stars 28 forks source link

node 8 buffers are now zero initialized … #12

Closed rarms-mylo closed 7 years ago

rarms-mylo commented 7 years ago

…so the _readChunk method would never exit if a line didn't end with a newline.

In node < 8, new buffers were not initialized so the _readChunk look would eventually allocate a buffer with a newline character in the random data. But the readSync calls would all have returned 0 bytes read so the _readChunk would return 0.

Starting with node 8, new Buffers are zero initialized so the loop (buffer allocate>readSync>Check for newline) would never exit. If eofReached is set to true, this avoids all this and returns immediately.

nacholibre commented 7 years ago

It's fixed in the new version. Thanks for you feedback.