★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/94528f510eNouvelle recherche | Portail wanayoo
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 richardlau committed Sep 1, 2020
1 parent 90f9348 commit 94528f510e431dfd9003799510ea404a3dde703e
Showing with 3 additions and 6 deletions.
  1. +3 −6 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);

0 comments on commit 94528f5

Please sign in to comment.