mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
b0e6f10530
commit
fd912a37a0
1 file changed
+12
-10
+12
-10
@@ -50,17 +50,19 @@ function Duplex(options) {
|
||||
|
||||
Readable.call(this, options);
|
||||
Writable.call(this, options);
|
||||
|
||||
if (options && options.readable === false)
|
||||
this.readable = false;
|
||||
|
||||
if (options && options.writable === false)
|
||||
this.writable = false;
|
||||
|
||||
this.allowHalfOpen = true;
|
||||
if (options && options.allowHalfOpen === false) {
|
||||
this.allowHalfOpen = false;
|
||||
this.once('end', onend);
|
||||
|
||||
if (options) {
|
||||
if (options.readable === false)
|
||||
this.readable = false;
|
||||
|
||||
if (options.writable === false)
|
||||
this.writable = false;
|
||||
|
||||
if (options.allowHalfOpen === false) {
|
||||
this.allowHalfOpen = false;
|
||||
this.once('end', onend);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user