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) {