Created
March 3, 2013 02:02
-
-
Save isaacs/5074143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js | |
index 8db4f55..debbab6 100644 | |
--- a/lib/_stream_writable.js | |
+++ b/lib/_stream_writable.js | |
@@ -313,19 +313,17 @@ Writable.prototype.end = function(chunk, encoding, cb) { | |
encoding = null; | |
} | |
- if (chunk) | |
+ if (typeof chunk !== 'undefined' && chunk !== null) | |
this.write(chunk, encoding); | |
// ignore unnecessary end() calls. | |
if (!state.ending && !state.ended && !state.finished) | |
- endWritable(this, state, !!chunk, cb); | |
+ endWritable(this, state, cb); | |
}; | |
-function endWritable(stream, state, hadChunk, cb) { | |
+function endWritable(stream, state, cb) { | |
state.ending = true; | |
- if (!hadChunk && | |
- state.length === 0 && | |
- !state.finishing) { | |
+ if (state.length === 0 && !state.finishing) { | |
state.finishing = true; | |
stream.emit('finish'); | |
state.finished = true; | |
@@ -337,4 +335,4 @@ function endWritable(stream, state, hadChunk, cb) { | |
stream.once('finish', cb); | |
} | |
state.ended = true; | |
-}; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment