Sitelet https://web.archive.org/web/20220320093009/https://github.com/nodejs/node/commit/cda459ecb0
Skip to content
Permalink
Browse files
zlib: replace usage of internal stream state with public api
Refs: #445

PR-URL: #34884
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
lundibundi authored and addaleax committed Sep 22, 2020
1 parent 481cced commit cda459ecb09b08c49d57f63debc8ae530101b477
Showing with 3 additions and 6 deletions.
  1. +3 −6 lib/zlib.js
@@ -349,17 +349,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 {
@@ -386,8 +384,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);

0 comments on commit cda459e

Please sign in to comment.