diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 8547957944af25..99069c54c9b3e6 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -93,13 +93,16 @@ function ReadableState(options, stream, isDuplex) { if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Stream.Duplex; - // Object stream flag. Used to make read(n) ignore n and to - // make all the buffer merging and length checks go away - this.objectMode = !!(options && options.objectMode); + if (options) { + // Object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; - if (isDuplex) - this.objectMode = this.objectMode || - !!(options && options.readableObjectMode); + if (isDuplex && !this.objectMode) + this.objectMode = !!options.readableObjectMode; + } else { + this.objectMode = false; + } // The point at which it stops calling _read() to fill the buffer // Note: 0 is a valid value, means "don't call _read preemptively ever"