Skip to content

Commit

Permalink
stream: only check options once in Duplex ctor
Browse files Browse the repository at this point in the history
This commit updates the Duplex constructor adding an if statement
checking if options is undefined, and removes the check from the
following three if statements.

PR-URL: #20353
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
danbev authored and BridgeAR committed Apr 28, 2018
1 parent e797d5b commit 65021c5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 65021c5

Please sign in to comment.