Skip to content

Commit fd912a3

Browse files
danbevMylesBorins
authored andcommitted
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. PR-URL: #20353 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent b0e6f10 commit fd912a3

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/_stream_duplex.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,19 @@ function Duplex(options) {
5050

5151
Readable.call(this, options);
5252
Writable.call(this, options);
53+
this.allowHalfOpen = true;
5354

54-
if (options && options.readable === false)
55-
this.readable = false;
55+
if (options) {
56+
if (options.readable === false)
57+
this.readable = false;
5658

57-
if (options && options.writable === false)
58-
this.writable = false;
59+
if (options.writable === false)
60+
this.writable = false;
5961

60-
this.allowHalfOpen = true;
61-
if (options && options.allowHalfOpen === false) {
62-
this.allowHalfOpen = false;
63-
this.once('end', onend);
62+
if (options.allowHalfOpen === false) {
63+
this.allowHalfOpen = false;
64+
this.once('end', onend);
65+
}
6466
}
6567
}
6668

0 commit comments

Comments
 (0)