mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
zlib: replace usage of internal stream state with public api
Refs: https://github.com/nodejs/node/issues/445 PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
dbc5c172cc
commit
7fca0df180
1 file changed
+3
-6
+3
-6
@@ -360,17 +360,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 {
|
||||
@@ -397,8 +395,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);
|
||||
|
||||
Reference in new issue
Block a user