diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 13b5a7474d..5d33f77cf1 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -394,11 +394,10 @@ Readable.prototype.read = function (n) { }; function chunkInvalid(state, chunk) { - var er = null; - if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); - } - return er; + if (chunk || Buffer.isBuffer(chunk) || typeof chunk === 'string' || chunk instanceof Uint8Array || state.objectMode) + return null; + + return new TypeError('Invalid non-string/buffer chunk'); } function onEofChunk(stream, state) { @@ -938,4 +937,4 @@ function indexOf(xs, x) { if (xs[i] === x) return i; } return -1; -} \ No newline at end of file +}