summaryrefslogtreecommitdiff
path: root/lib/_stream_duplex.js
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-08-02 08:09:06 +0200
committerRich Trott <rtrott@gmail.com>2019-08-17 00:28:06 -0700
commit6f613d8abb05619e35c828b665a76215861bbf04 (patch)
tree18a904d44299c6564c5c83adc0051076f27bb922 /lib/_stream_duplex.js
parente4bbbcc84bd10be1e9e8e66d42542c70c1a02056 (diff)
downloadandroid-node-v8-6f613d8abb05619e35c828b665a76215861bbf04.tar.gz
android-node-v8-6f613d8abb05619e35c828b665a76215861bbf04.tar.bz2
android-node-v8-6f613d8abb05619e35c828b665a76215861bbf04.zip
http,stream: add writableEnded
This is work towards resolving the response.finished confusion and future deprecation. Note that implementation-wise, streams have both an ending and ended state. However, in this case (in order to avoid confusion in user space) writableEnded is equal to writable.ending. The ending vs ended situation is internal state required for internal stream logic. PR-URL: https://github.com/nodejs/node/pull/28934 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/_stream_duplex.js')
-rw-r--r--lib/_stream_duplex.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js
index d20877e921..b96a0439f7 100644
--- a/lib/_stream_duplex.js
+++ b/lib/_stream_duplex.js
@@ -74,7 +74,7 @@ Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
// userland will fail
enumerable: false,
get() {
- return this._writableState.highWaterMark;
+ return this._writableState && this._writableState.highWaterMark;
}
});
@@ -94,7 +94,7 @@ Object.defineProperty(Duplex.prototype, 'writableLength', {
// userland will fail
enumerable: false,
get() {
- return this._writableState.length;
+ return this._writableState && this._writableState.length;
}
});
@@ -104,7 +104,17 @@ Object.defineProperty(Duplex.prototype, 'writableFinished', {
// userland will fail
enumerable: false,
get() {
- return this._writableState.finished;
+ return this._writableState ? this._writableState.finished : false;
+ }
+});
+
+Object.defineProperty(Duplex.prototype, 'writableEnded', {
+ // Making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get() {
+ return this._writableState ? this._writableState.ending : false;
}
});