diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index b123cdcb4d776f..7059757dbd44b1 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -50,17 +50,19 @@ function Duplex(options) { Readable.call(this, options); Writable.call(this, options); + this.allowHalfOpen = true; - if (options && options.readable === false) - this.readable = false; + if (options) { + if (options.readable === false) + this.readable = false; - if (options && options.writable === false) - this.writable = false; + if (options.writable === false) + this.writable = false; - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) { - this.allowHalfOpen = false; - this.once('end', onend); + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once('end', onend); + } } }