Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created March 3, 2013 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/5074143 to your computer and use it in GitHub Desktop.
Save isaacs/5074143 to your computer and use it in GitHub Desktop.
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