diff options
author | Luigi Pinca <luigipinca@gmail.com> | 2018-04-03 18:51:30 +0200 |
---|---|---|
committer | Luigi Pinca <luigipinca@gmail.com> | 2018-04-06 10:23:22 +0200 |
commit | 496d6023e0c372c76746c35fdba800fa943cbffc (patch) | |
tree | 1ded5c50a5dde88c7fb1b40c8869fb896619520f /lib/_stream_duplex.js | |
parent | dca09a77d5a554ae51bc0fd4b047274b8f62bf53 (diff) | |
download | android-node-v8-496d6023e0c372c76746c35fdba800fa943cbffc.tar.gz android-node-v8-496d6023e0c372c76746c35fdba800fa943cbffc.tar.bz2 android-node-v8-496d6023e0c372c76746c35fdba800fa943cbffc.zip |
net,stream: remove DuplexBase
`DuplexBase` was added to prevent the "no-half-open enforcer" from
being inherited by `net.Socket`. The main reason to use it instead
of `Duplex` was that it allowed to not copy the options object but
since commit 5e3f516 the options object is copyed anyway so it is
no longer useful.
PR-URL: https://github.com/nodejs/node/pull/19779
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/_stream_duplex.js')
-rw-r--r-- | lib/_stream_duplex.js | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index 522b94d660..b123cdcb4d 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -29,15 +29,33 @@ module.exports = Duplex; const util = require('util'); -const DuplexBase = require('internal/streams/duplex_base'); - -util.inherits(Duplex, DuplexBase); +const Readable = require('_stream_readable'); +const Writable = require('_stream_writable'); + +util.inherits(Duplex, Readable); + +{ + // Allow the keys array to be GC'ed. + const keys = Object.keys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { + const method = keys[v]; + if (!Duplex.prototype[method]) + Duplex.prototype[method] = Writable.prototype[method]; + } +} function Duplex(options) { if (!(this instanceof Duplex)) return new Duplex(options); - DuplexBase.call(this, 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) { |