Skip to content

Commit 94528f5

Browse files
lundibundirichardlau
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 90f9348 commit 94528f5

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/zlib.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -355,17 +355,15 @@ const kFlushBuffers = [];
355355
}
356356

357357
ZlibBase.prototype.flush = function(kind, callback) {
358-
const ws = this._writableState;
359-
360358
if (typeof kind === 'function' || (kind === undefined && !callback)) {
361359
callback = kind;
362360
kind = this._defaultFullFlushFlag;
363361
}
364362

365-
if (ws.ended) {
363+
if (this.writableFinished) {
366364
if (callback)
367365
process.nextTick(callback);
368-
} else if (ws.ending) {
366+
} else if (this.writableEnded) {
369367
if (callback)
370368
this.once('end', callback);
371369
} else {
@@ -392,8 +390,7 @@ ZlibBase.prototype._transform = function(chunk, encoding, cb) {
392390
}
393391

394392
// For the last chunk, also apply `_finishFlushFlag`.
395-
const ws = this._writableState;
396-
if ((ws.ending || ws.ended) && ws.length === chunk.byteLength) {
393+
if (this.writableEnded && this.writableLength === chunk.byteLength) {
397394
flushFlag = maxFlush(flushFlag, this._finishFlushFlag);
398395
}
399396
processChunk(this, chunk, flushFlag, cb);

0 commit comments

Comments
 (0)