From 54b2d81b0fa737a7df36874c6b99aedbc70da080 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Mon, 5 Aug 2019 11:42:02 +0200 Subject: [PATCH] stream: writableComplete --- lib/_stream_writable.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index bf9abeeed81d45..0530f2ab642bff 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -725,6 +725,18 @@ Object.defineProperty(Writable.prototype, 'writableFinished', { } }); +Object.defineProperty(Writable.prototype, 'writableComplete', { + // 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 || + this._writableState.destroyed; + } +}); + Writable.prototype.destroy = destroyImpl.destroy; Writable.prototype._undestroy = destroyImpl.undestroy; Writable.prototype._destroy = function(err, cb) {