summaryrefslogtreecommitdiff
path: root/lib/_stream_duplex.js
diff options
context:
space:
mode:
authorzero1five <zerodengyin@gmail.com>2019-06-02 03:04:56 +0800
committerRich Trott <rtrott@gmail.com>2019-06-25 14:46:10 -0700
commit33aef82b42ca689411673784e203e59d3f4eb142 (patch)
tree2d329d20782e537d53507f5fbe98897803149273 /lib/_stream_duplex.js
parent2bb93e11085ea582aea1636f544d900520d479ed (diff)
downloadandroid-node-v8-33aef82b42ca689411673784e203e59d3f4eb142.tar.gz
android-node-v8-33aef82b42ca689411673784e203e59d3f4eb142.tar.bz2
android-node-v8-33aef82b42ca689411673784e203e59d3f4eb142.zip
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 <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/_stream_duplex.js')
-rw-r--r--lib/_stream_duplex.js10
1 files changed, 10 insertions, 0 deletions
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.