@@ -238,9 +238,13 @@ const checkRangesOrGetDefault = hideStackFrames(
238
238
}
239
239
) ;
240
240
241
+ const FLUSH_BOUND = [
242
+ [ Z_NO_FLUSH , Z_BLOCK ] ,
243
+ [ BROTLI_OPERATION_PROCESS , BROTLI_OPERATION_EMIT_METADATA ] ,
244
+ ] ;
241
245
function isBrotliHandle ( handle ) {
242
- return ( handle instanceof binding . BrotliEncoder ) ||
243
- ( handle instanceof binding . BrotliDecoder ) ;
246
+ return ( ( handle instanceof binding . BrotliEncoder ) ||
247
+ ( handle instanceof binding . BrotliDecoder ) ) ? 1 : 0 ;
244
248
}
245
249
246
250
// The base class for all Zlib-style streams.
@@ -263,23 +267,13 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) {
263
267
`>= ${ Z_MIN_CHUNK } ` , chunkSize ) ;
264
268
}
265
269
266
- if ( ! isBrotli ) {
267
- flush = checkRangesOrGetDefault (
268
- opts . flush , 'options.flush' ,
269
- Z_NO_FLUSH , Z_BLOCK , flush ) ;
270
+ flush = checkRangesOrGetDefault (
271
+ opts . flush , 'options.flush' ,
272
+ FLUSH_BOUND [ isBrotli ] [ 0 ] , FLUSH_BOUND [ isBrotli ] [ 1 ] , flush ) ;
270
273
271
- finishFlush = checkRangesOrGetDefault (
272
- opts . finishFlush , 'options.finishFlush' ,
273
- Z_NO_FLUSH , Z_BLOCK , finishFlush ) ;
274
- } else {
275
- flush = checkRangesOrGetDefault (
276
- opts . flush , 'options.flush' ,
277
- BROTLI_OPERATION_PROCESS , BROTLI_OPERATION_EMIT_METADATA , flush ) ;
278
-
279
- finishFlush = checkRangesOrGetDefault (
280
- opts . finishFlush , 'options.finishFlush' ,
281
- BROTLI_OPERATION_PROCESS , BROTLI_OPERATION_EMIT_METADATA , finishFlush ) ;
282
- }
274
+ finishFlush = checkRangesOrGetDefault (
275
+ opts . finishFlush , 'options.finishFlush' ,
276
+ FLUSH_BOUND [ isBrotli ] [ 0 ] , FLUSH_BOUND [ isBrotli ] [ 1 ] , finishFlush ) ;
283
277
284
278
maxOutputLength = checkRangesOrGetDefault (
285
279
opts . maxOutputLength , 'options.maxOutputLength' ,
0 commit comments