Skip to content

Commit

Permalink
if 0 len callback
Browse files Browse the repository at this point in the history
  • Loading branch information
joeferner committed Aug 8, 2012
1 parent 6e9d85f commit e7c0e88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pullstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ PullStream.prototype.pull = over([
]);

PullStream.prototype._pull = function (len, callback) {
if (len === 0) {
return callback(null, new Buffer(0));
}

var self = this;
var lenLeft = len;
var resultBuffer = new streamBuffers.WritableStreamBuffer({
Expand Down Expand Up @@ -89,6 +93,10 @@ PullStream.prototype.pipe = over([
]);

PullStream.prototype._pipe = function (len, destStream) {
if (len === 0) {
return callback(null, new Buffer(0));
}

var self = this;
this._emitter.on('data', dataOrEnd.bind(this, 'data'));
this._emitter.on('end', dataOrEnd.bind(this, 'end'));
Expand Down
1 change: 0 additions & 1 deletion test/pullStreamTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ test("read from file", function (t) {

var ps = new PullStream();
ps.on('end', function () {
sourceStream.destroy();
t.end();
});

Expand Down

0 comments on commit e7c0e88

Please sign in to comment.