Skip to content

Commit

Permalink
git rid of eachLine passing the reader to the done callback (this was…
Browse files Browse the repository at this point in the history
… only done for testing, but I made another workaround)
  • Loading branch information
jedwards1211 committed Aug 31, 2015
1 parent 32abd5f commit 31a61b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/line_reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@
}

if (err) {
if (cb) cb(err, reader);
if (cb) cb(err);
return;
}

function finish(err) {
reader.close(function(err2) {
if (cb) cb(err || err2, reader);
if (cb) cb(err || err2);
});
}

Expand Down
7 changes: 5 additions & 2 deletions test/line_reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,22 @@ describe("lineReader", function() {
});

it("should close the file when eachLine finishes", function(done) {
var reader;
lineReader.eachLine(oneLineFilePath, function(line, last) {
return false;
}, function(err, reader) {
}, function(err) {
assert.ok(!err);
assert.ok(reader.isClosed());
done();
}).getReader(function(_reader) {
reader = _reader;
});
});

it("should close the file if there is an error during eachLine", function(done) {
var reader;
lineReader.eachLine(testFilePath, {bufferSize: 10}, function(line, last) {
}, function(err, reader) {
}, function(err) {
delete readErrorFds[reader.fd()];
assert.ok(err);
assert.ok(reader.isClosed());
Expand Down

0 comments on commit 31a61b3

Please sign in to comment.