readable-stream
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -55,2 +55,8 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
// In streams that never have any data, and do push(null) right away, | ||
// the consumer can miss the 'end' event if they do some I/O before | ||
// consuming the stream. So, we don't emit('end') until some reading | ||
// happens. | ||
this.calledRead = false; | ||
// a flag to be able to tell if the onwrite cb is called immediately, | ||
@@ -225,2 +231,3 @@ // or on a later tick. We set this to true at first, becuase any | ||
var state = this._readableState; | ||
state.calledRead = true; | ||
var nOrig = n; | ||
@@ -402,3 +409,3 @@ | ||
while (!state.reading && !state.flowing && !state.ended && | ||
state.length < state.highWaterMark) { | ||
state.length < state.highWaterMark) { | ||
stream.read(0); | ||
@@ -439,10 +446,12 @@ if (len === state.length) | ||
if ((!pipeOpts || pipeOpts.end !== false) && | ||
dest !== process.stdout && | ||
dest !== process.stderr) { | ||
src.once('end', onend); | ||
} else { | ||
src.once('end', cleanup); | ||
} | ||
var doEnd = (!pipeOpts || pipeOpts.end !== false) && | ||
dest !== process.stdout && | ||
dest !== process.stderr; | ||
var endFn = doEnd ? onend : cleanup; | ||
if (state.endEmitted) | ||
process.nextTick(endFn); | ||
else | ||
src.once('end', endFn); | ||
dest.on('unpipe', onunpipe); | ||
@@ -863,10 +872,10 @@ function onunpipe(readable) { | ||
if (state.endEmitted) | ||
return; | ||
state.ended = true; | ||
state.endEmitted = true; | ||
process.nextTick(function() { | ||
stream.readable = false; | ||
stream.emit('end'); | ||
}); | ||
if (!state.endEmitted && state.calledRead) { | ||
state.ended = true; | ||
state.endEmitted = true; | ||
process.nextTick(function() { | ||
stream.readable = false; | ||
stream.emit('end'); | ||
}); | ||
} | ||
} |
{ | ||
"name": "readable-stream", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "An exploration of a new kind of readable streams for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "readable.js", |
@@ -28,3 +28,4 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
test1(); | ||
if (!/v0\.8\./.test(process.version)) test2(); | ||
if (!/^v0\.[0-8]\./.test(process.version)) | ||
test2(); | ||
@@ -31,0 +32,0 @@ function test1() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
209353
5693