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:
Daniel Bevenius authored and Myles Borins committed 2018-05-04 11:54:32 -04:00
1 parent b0e6f10530
commit fd912a37a0
1 file changed
+12 -10
+12 -10
View File
@@ -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);
}
}
}