Handles scenarios where lines might not end with a newline at the end of the file. Fixes #49.
This commit is contained in:
parent
9d8a81592f
commit
f8ed81ad5a
1 changed files with 2 additions and 2 deletions
|
|
@ -411,13 +411,13 @@ exports.LineReader.prototype = {
|
|||
if(this.currentPosition === -1) return false;
|
||||
}
|
||||
|
||||
if(this.buffer.indexOf("\n") > -1) return true;
|
||||
if(this.buffer.indexOf("\n") > -1 || this.buffer.length !== 0) return true;
|
||||
return false;
|
||||
},
|
||||
|
||||
getNextLine: function() {
|
||||
var lineEnd = this.buffer.indexOf("\n"),
|
||||
result = this.buffer.substring(0, lineEnd);
|
||||
result = this.buffer.substring(0, lineEnd ? lineEnd : this.buffer.length);
|
||||
|
||||
this.buffer = this.buffer.substring(result.length + 1, this.buffer.length);
|
||||
return result;
|
||||
|
|
|
|||
Reference in a new issue