RustyMarvin / line-by-line

A NodeJS module that helps you reading large text files, line by line, without buffering the files into memory.
MIT License
42 stars 39 forks source link

"end" emitted prematurely and twice for paused last line #1

Open dertseha opened 11 years ago

dertseha commented 11 years ago

When pausing the "line" events after each line (and resuming asynchronously), the "end" event is fired while still processing the last line; After resuming, "end" is emitted a second time.

I made a quick look into LineByLineReader.prototype._nextLine and modified the sequence for me. It works for my case, but can't tell whether all are covered:

    if (this._lines.length === 0) {
        if (this._end) {
            this.emit('end');
        } else {
            this._readStream.resume();
        }
        return;
    }
ebrandel commented 10 years ago

This fixed my issues as well

rdev5 commented 10 years ago

Same here.

tkurki commented 10 years ago

Could you please consider fixing this?

line-by-line is useful but 0.1 works incorrectly, whereas @Osterjour 's version works ok.

Osterjour commented 10 years ago

I just sent an email @RustyMarvin and asked him to add me as an owner on npmjs for this package. As my pull request (and all other) aren't handled I think @RustyMarvin has lost the interest (or the time) to maintain the package. Hopefully @RustyMarvin answers this and we can push the npm package to a working version!