diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-04-27 09:39:24 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-04-28 17:13:55 +0200 |
commit | 65021c5632df10e40b102c29f2a5711b9acbcb01 (patch) | |
tree | 4c0cb19e11117818c18d2917f8b622ed29fa0549 /lib | |
parent | e797d5babd119900034953a65efe90ed06ed97b9 (diff) | |
download | android-node-v8-65021c5632df10e40b102c29f2a5711b9acbcb01.tar.gz android-node-v8-65021c5632df10e40b102c29f2a5711b9acbcb01.tar.bz2 android-node-v8-65021c5632df10e40b102c29f2a5711b9acbcb01.zip |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_stream_duplex.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index b123cdcb4d..7059757dbd 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -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); + } } } |