From 33aef82b42ca689411673784e203e59d3f4eb142 Mon Sep 17 00:00:00 2001 From: zero1five Date: Sun, 2 Jun 2019 03:04:56 +0800 Subject: stream: add writableFinished add a new getter to duplex stream to replace the property `this .writableState.finished` of the object that inherited duplex. Refs: https://github.com/nodejs/node/issues/445 PR-URL: https://github.com/nodejs/node/pull/28007 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- lib/_stream_duplex.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/_stream_duplex.js') diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js index 49520c4074..d20877e921 100644 --- a/lib/_stream_duplex.js +++ b/lib/_stream_duplex.js @@ -98,6 +98,16 @@ Object.defineProperty(Duplex.prototype, 'writableLength', { } }); +Object.defineProperty(Duplex.prototype, 'writableFinished', { + // Making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get() { + return this._writableState.finished; + } +}); + // The no-half-open enforcer function onend() { // If the writable side ended, then we're ok. -- cgit v1.2.3