diff --git a/lib/zlib.js b/lib/zlib.js index 829a472e35b6a4..609c50afd52f22 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -355,17 +355,15 @@ const kFlushBuffers = []; } ZlibBase.prototype.flush = function(kind, callback) { - const ws = this._writableState; - if (typeof kind === 'function' || (kind === undefined && !callback)) { callback = kind; kind = this._defaultFullFlushFlag; } - if (ws.ended) { + if (this.writableFinished) { if (callback) process.nextTick(callback); - } else if (ws.ending) { + } else if (this.writableEnded) { if (callback) this.once('end', callback); } else { @@ -392,8 +390,7 @@ ZlibBase.prototype._transform = function(chunk, encoding, cb) { } // For the last chunk, also apply `_finishFlushFlag`. - const ws = this._writableState; - if ((ws.ending || ws.ended) && ws.length === chunk.byteLength) { + if (this.writableEnded && this.writableLength === chunk.byteLength) { flushFlag = maxFlush(flushFlag, this._finishFlushFlag); } processChunk(this, chunk, flushFlag, cb);