Skip to content

Commit

Permalink
stream: let Duplex re-use Writable properties
Browse files Browse the repository at this point in the history
Instead of reimplementing Writable properties, fetch them
from the Writable prototype.

PR-URL: #33079
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
ronag authored and targos committed May 4, 2020
1 parent 92c7e06 commit b183d0a
Showing 1 changed file with 14 additions and 37 deletions.
51 changes: 14 additions & 37 deletions lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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;
}
}
});

0 comments on commit b183d0a

Please sign in to comment.