Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
stream: only check options once in Duplex ctor
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.
  • Loading branch information
danbev committed Apr 27, 2018
commit 9fe915a3f9bf13992ed3d61ae1b88ee87a0726a4
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