diff options
author | James Halliday <mail@substack.net> | 2014-06-08 18:58:53 -0700 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2014-08-01 13:01:23 -0700 |
commit | 8e2cc69e7883b0a8d97a2f62e301ece209f61352 (patch) | |
tree | aa65969debf8820834ac55a4dc04a0aa42846bcf /lib | |
parent | 92518892ec8d99a04cee9d51ab071087f06032d2 (diff) | |
download | nodejs-8e2cc69e7883b0a8d97a2f62e301ece209f61352.tar.gz nodejs-8e2cc69e7883b0a8d97a2f62e301ece209f61352.tar.bz2 nodejs-8e2cc69e7883b0a8d97a2f62e301ece209f61352.zip |
stream: fix Readable.wrap objectMode falsy values
A streams1 stream will have its falsy values such as 0, false, or ""
eaten by the upgrade to streams2, even when objectMode is enabled.
Include test for said cases.
Reviewed-by: isaacs <i@izs.me>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/_stream_readable.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index ae04f22fe..1b29676e0 100755 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -810,7 +810,12 @@ Readable.prototype.wrap = function(stream) { stream.on('data', function(chunk) { if (state.decoder) chunk = state.decoder.write(chunk); - if (!chunk || !state.objectMode && !chunk.length) + + // don't skip over falsy values in objectMode + //if (state.objectMode && util.isNullOrUndefined(chunk)) + if (state.objectMode && (chunk === null || chunk === undefined)) + return; + else if (!state.objectMode && (!chunk || !chunk.length)) return; var ret = self.push(chunk); |