Skip to content

Commit 7fca0df

Browse files
lundibundinodejs-github-bot
authored andcommitted
zlib: replace usage of internal stream state with public api
Refs: #445 PR-URL: #34884 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent dbc5c17 commit 7fca0df

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/zlib.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,17 +360,15 @@ const kFlushBuffers = [];
360360
}
361361

362362
ZlibBase.prototype.flush = function(kind, callback) {
363-
const ws = this._writableState;
364-
365363
if (typeof kind === 'function' || (kind === undefined && !callback)) {
366364
callback = kind;
367365
kind = this._defaultFullFlushFlag;
368366
}
369367

370-
if (ws.ended) {
368+
if (this.writableFinished) {
371369
if (callback)
372370
process.nextTick(callback);
373-
} else if (ws.ending) {
371+
} else if (this.writableEnded) {
374372
if (callback)
375373
this.once('end', callback);
376374
} else {
@@ -397,8 +395,7 @@ ZlibBase.prototype._transform = function(chunk, encoding, cb) {
397395
}
398396

399397
// For the last chunk, also apply `_finishFlushFlag`.
400-
const ws = this._writableState;
401-
if ((ws.ending || ws.ended) && ws.length === chunk.byteLength) {
398+
if (this.writableEnded && this.writableLength === chunk.byteLength) {
402399
flushFlag = maxFlush(flushFlag, this._finishFlushFlag);
403400
}
404401
processChunk(this, chunk, flushFlag, cb);

0 commit comments

Comments
 (0)