Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Commit

Permalink
Handles scenarios where lines might not end with a newline at the end…
Browse files Browse the repository at this point in the history
… of the file. Fixes #49.
  • Loading branch information
Ryan McGrath committed May 3, 2013
1 parent 9d8a815 commit f8ed81a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/wrench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f8ed81a

Please sign in to comment.