diff options
author | Robert Nagy <ronagy@icloud.com> | 2020-04-26 19:38:43 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2020-05-04 14:23:23 +0200 |
commit | b183d0a18a9c5391a7cfd253d713ebf0ca497bca (patch) | |
tree | 7efdcc11135dc68d3739ceac241df235484304e9 | |
parent | 92c7e0620f83f0db76a5b8264d6e4b380176f869 (diff) | |
download | node-new-b183d0a18a9c5391a7cfd253d713ebf0ca497bca.tar.gz |
stream: let Duplex re-use Writable properties
Instead of reimplementing Writable properties, fetch them
from the Writable prototype.
PR-URL: https://github.com/nodejs/node/pull/33079
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
-rw-r--r-- | lib/_stream_duplex.js | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index 07a16175ff..ced361c8d6 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -71,7 +71,20 @@ function Duplex(options) { } ObjectDefineProperties(Duplex.prototype, { - writable: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writable'), + writable: + ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writable'), + writableHighWaterMark: + ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableHighWaterMark'), + writableBuffer: + ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableBuffer'), + writableLength: + ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableLength'), + writableFinished: + ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableFinished'), + writableCorked: + ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableCorked'), + writableEnded: + ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableEnded'), destroyed: { get() { @@ -89,41 +102,5 @@ ObjectDefineProperties(Duplex.prototype, { this._writableState.destroyed = value; } } - }, - - writableHighWaterMark: { - get() { - return this._writableState && this._writableState.highWaterMark; - } - }, - - writableBuffer: { - get() { - return this._writableState && this._writableState.getBuffer(); - } - }, - - writableLength: { - get() { - return this._writableState && this._writableState.length; - } - }, - - writableFinished: { - get() { - return this._writableState ? this._writableState.finished : false; - } - }, - - writableCorked: { - get() { - return this._writableState ? this._writableState.corked : 0; - } - }, - - writableEnded: { - get() { - return this._writableState ? this._writableState.ending : false; - } } }); |