Skip to content

Commit

Permalink
fixed #8 - nodify broken in streamline callbacks mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bjouhier committed Sep 20, 2014
1 parent fefcaf0 commit e32f382
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/reader._js
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,21 @@ exports.decorate = function(proto) {
var self = this;
var stream = new (require('stream').Readable)();
var pending = false;
function end() {
stream.emit('end');
}
function more() {
if (pending) return;
var sync = true;
pending = true;
self.read(_ >> function(err, result) {
pending = false;
if (err) stream.emit('error', err);
if (err) return stream.emit('error', err);
if (result === undefined) {
if (sync) setImmediate(end);
else end();
return;
}
if (stream.push(result)) {
if (sync) setImmediate(more);
else more();
Expand Down

0 comments on commit e32f382

Please sign in to comment.