@@ -294,9 +294,12 @@ ObjectDefineProperty(ZlibBase.prototype, 'bytesRead', {
294294 'This feature will be removed in the future.' , 'DEP0108' ) ,
295295} ) ;
296296
297+ /**
298+ * @this ZlibBase
299+ * @returns {void }
300+ */
297301ZlibBase . prototype . reset = function ( ) {
298- if ( ! this . _handle )
299- assert ( false , 'zlib binding closed' ) ;
302+ assert ( this . _handle , 'zlib binding closed' ) ;
300303 return this . _handle . reset ( ) ;
301304} ;
302305
@@ -358,6 +361,10 @@ ZlibBase.prototype.flush = function(kind, callback) {
358361 }
359362} ;
360363
364+ /**
365+ * @this import('stream').Transform
366+ * @param {(err?: Error) => any } [callback]
367+ */
361368ZlibBase . prototype . close = function ( callback ) {
362369 if ( callback ) finished ( this , callback ) ;
363370 this . destroy ( ) ;
@@ -398,7 +405,7 @@ function processChunkSync(self, chunk, flushFlag) {
398405 let availOutAfter ;
399406 let availInAfter ;
400407
401- let buffers = null ;
408+ const buffers = [ ] ;
402409 let nread = 0 ;
403410 let inputRead = 0 ;
404411 const state = self . _writeState ;
@@ -435,10 +442,7 @@ function processChunkSync(self, chunk, flushFlag) {
435442 if ( have > 0 ) {
436443 const out = buffer . slice ( offset , offset + have ) ;
437444 offset += have ;
438- if ( ! buffers )
439- buffers = [ out ] ;
440- else
441- ArrayPrototypePush ( buffers , out ) ;
445+ ArrayPrototypePush ( buffers , out ) ;
442446 nread += out . byteLength ;
443447
444448 if ( nread > self . _maxOutputLength ) {
@@ -589,12 +593,13 @@ function processCallback() {
589593 this . cb ( ) ;
590594}
591595
596+ /**
597+ * @param {ZlibBase } engine
598+ * @private
599+ */
592600function _close ( engine ) {
593- // Caller may invoke .close after a zlib error (which will null _handle).
594- if ( ! engine . _handle )
595- return ;
596-
597- engine . _handle . close ( ) ;
601+ // Caller may invoke .close after a zlib error (which will null _handle)
602+ engine . _handle ?. close ( ) ;
598603 engine . _handle = null ;
599604}
600605
0 commit comments