Skip to content

Commit

Permalink
Merge 4778da1 into f3801d6
Browse files Browse the repository at this point in the history
  • Loading branch information
plk3000 committed Sep 28, 2016
2 parents f3801d6 + 4778da1 commit 7cf87cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var fs = require('fs');
var events = require('events');
var iconv = require('iconv-lite');

var readline = function(path, bufferSize, encoding, lineEnding) {
this.bufferSize = bufferSize || 8000;
this.encoding = encoding || 'utf8';
Expand Down Expand Up @@ -45,7 +47,7 @@ readline.prototype.read = function() {
len = (this.pos + this.bufferSize >= fileSize) ? remeaning : this.bufferSize;
fs.read(this.fd, this.buffer, 0, len, this.pos, function(err, bytesRead) {
this.pos += len;
textRead = this.buffer.toString(this.encoding, 0, bytesRead);
textRead = iconv.decode(this.buffer.slice(0, bytesRead), this.encoding);
this.cache = textRead.split(this.lineEnding);
this.cache[0] = this.leftover + this.cache[0];
this.leftover = this.cache.pop();
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"url": "http://github.com/alfonsodev/read-lines"
},
"dependencies": {
"iconv-lite": "^0.4.13"
},
"devDependencies": {
"mocha": "~1.17.0",
Expand Down

0 comments on commit 7cf87cc

Please sign in to comment.