2323
2424const {
2525 ArrayBuffer,
26+ ArrayPrototypeMap,
27+ ArrayPrototypePush,
2628 Error,
29+ FunctionPrototypeBind,
2730 MathMax,
2831 NumberIsFinite,
2932 NumberIsNaN,
@@ -33,7 +36,9 @@ const {
3336 ObjectGetPrototypeOf,
3437 ObjectKeys,
3538 ObjectSetPrototypeOf,
39+ ReflectApply,
3640 Symbol,
41+ TypedArrayPrototypeFill,
3742 Uint32Array,
3843} = primordials ;
3944
@@ -123,7 +128,7 @@ function zlibBufferOnData(chunk) {
123128 if ( ! this . buffers )
124129 this . buffers = [ chunk ] ;
125130 else
126- this . buffers . push ( chunk ) ;
131+ ArrayPrototypePush ( this . buffers , chunk ) ;
127132 this . nread += chunk . length ;
128133 if ( this . nread > this . _maxOutputLength ) {
129134 this . close ( ) ;
@@ -267,7 +272,7 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) {
267272 }
268273 }
269274
270- Transform . call ( this , { autoDestroy : true , ...opts } ) ;
275+ ReflectApply ( Transform , this , [ { autoDestroy : true , ...opts } ] ) ;
271276 this [ kError ] = null ;
272277 this . bytesWritten = 0 ;
273278 this . _handle = handle ;
@@ -452,7 +457,7 @@ function processChunkSync(self, chunk, flushFlag) {
452457 if ( ! buffers )
453458 buffers = [ out ] ;
454459 else
455- buffers . push ( out ) ;
460+ ArrayPrototypePush ( buffers , out ) ;
456461 nread += out . byteLength ;
457462
458463 if ( nread > self . _maxOutputLength ) {
@@ -665,7 +670,7 @@ function Zlib(opts, mode) {
665670 processCallback ,
666671 dictionary ) ;
667672
668- ZlibBase . call ( this , opts , mode , handle , zlibDefaultOpts ) ;
673+ ReflectApply ( ZlibBase , this , [ opts , mode , handle , zlibDefaultOpts ] ) ;
669674
670675 this . _level = level ;
671676 this . _strategy = strategy ;
@@ -693,7 +698,8 @@ Zlib.prototype.params = function params(level, strategy, callback) {
693698
694699 if ( this . _level !== level || this . _strategy !== strategy ) {
695700 this . flush ( Z_SYNC_FLUSH ,
696- paramsAfterFlushCallback . bind ( this , level , strategy , callback ) ) ;
701+ FunctionPrototypeBind ( paramsAfterFlushCallback , this ,
702+ level , strategy , callback ) ) ;
697703 } else {
698704 process . nextTick ( callback ) ;
699705 }
@@ -704,31 +710,31 @@ Zlib.prototype.params = function params(level, strategy, callback) {
704710function Deflate ( opts ) {
705711 if ( ! ( this instanceof Deflate ) )
706712 return new Deflate ( opts ) ;
707- Zlib . call ( this , opts , DEFLATE ) ;
713+ ReflectApply ( Zlib , this , [ opts , DEFLATE ] ) ;
708714}
709715ObjectSetPrototypeOf ( Deflate . prototype , Zlib . prototype ) ;
710716ObjectSetPrototypeOf ( Deflate , Zlib ) ;
711717
712718function Inflate ( opts ) {
713719 if ( ! ( this instanceof Inflate ) )
714720 return new Inflate ( opts ) ;
715- Zlib . call ( this , opts , INFLATE ) ;
721+ ReflectApply ( Zlib , this , [ opts , INFLATE ] ) ;
716722}
717723ObjectSetPrototypeOf ( Inflate . prototype , Zlib . prototype ) ;
718724ObjectSetPrototypeOf ( Inflate , Zlib ) ;
719725
720726function Gzip ( opts ) {
721727 if ( ! ( this instanceof Gzip ) )
722728 return new Gzip ( opts ) ;
723- Zlib . call ( this , opts , GZIP ) ;
729+ ReflectApply ( Zlib , this , [ opts , GZIP ] ) ;
724730}
725731ObjectSetPrototypeOf ( Gzip . prototype , Zlib . prototype ) ;
726732ObjectSetPrototypeOf ( Gzip , Zlib ) ;
727733
728734function Gunzip ( opts ) {
729735 if ( ! ( this instanceof Gunzip ) )
730736 return new Gunzip ( opts ) ;
731- Zlib . call ( this , opts , GUNZIP ) ;
737+ ReflectApply ( Zlib , this , [ opts , GUNZIP ] ) ;
732738}
733739ObjectSetPrototypeOf ( Gunzip . prototype , Zlib . prototype ) ;
734740ObjectSetPrototypeOf ( Gunzip , Zlib ) ;
@@ -737,23 +743,23 @@ function DeflateRaw(opts) {
737743 if ( opts && opts . windowBits === 8 ) opts . windowBits = 9 ;
738744 if ( ! ( this instanceof DeflateRaw ) )
739745 return new DeflateRaw ( opts ) ;
740- Zlib . call ( this , opts , DEFLATERAW ) ;
746+ ReflectApply ( Zlib , this , [ opts , DEFLATERAW ] ) ;
741747}
742748ObjectSetPrototypeOf ( DeflateRaw . prototype , Zlib . prototype ) ;
743749ObjectSetPrototypeOf ( DeflateRaw , Zlib ) ;
744750
745751function InflateRaw ( opts ) {
746752 if ( ! ( this instanceof InflateRaw ) )
747753 return new InflateRaw ( opts ) ;
748- Zlib . call ( this , opts , INFLATERAW ) ;
754+ ReflectApply ( Zlib , this , [ opts , INFLATERAW ] ) ;
749755}
750756ObjectSetPrototypeOf ( InflateRaw . prototype , Zlib . prototype ) ;
751757ObjectSetPrototypeOf ( InflateRaw , Zlib ) ;
752758
753759function Unzip ( opts ) {
754760 if ( ! ( this instanceof Unzip ) )
755761 return new Unzip ( opts ) ;
756- Zlib . call ( this , opts , UNZIP ) ;
762+ ReflectApply ( Zlib , this , [ opts , UNZIP ] ) ;
757763}
758764ObjectSetPrototypeOf ( Unzip . prototype , Zlib . prototype ) ;
759765ObjectSetPrototypeOf ( Unzip , Zlib ) ;
@@ -773,9 +779,10 @@ function createConvenienceMethod(ctor, sync) {
773779 } ;
774780}
775781
776- const kMaxBrotliParam = MathMax ( ...ObjectKeys ( constants ) . map ( ( key ) => {
777- return key . startsWith ( 'BROTLI_PARAM_' ) ? constants [ key ] : 0 ;
778- } ) ) ;
782+ const kMaxBrotliParam = MathMax ( ...ArrayPrototypeMap (
783+ ObjectKeys ( constants ) ,
784+ ( key ) => ( key . startsWith ( 'BROTLI_PARAM_' ) ? constants [ key ] : 0 )
785+ ) ) ;
779786
780787const brotliInitParamsArray = new Uint32Array ( kMaxBrotliParam + 1 ) ;
781788
@@ -787,7 +794,7 @@ const brotliDefaultOpts = {
787794function Brotli ( opts , mode ) {
788795 assert ( mode === BROTLI_DECODE || mode === BROTLI_ENCODE ) ;
789796
790- brotliInitParamsArray . fill ( - 1 ) ;
797+ TypedArrayPrototypeFill ( brotliInitParamsArray , - 1 ) ;
791798 if ( opts && opts . params ) {
792799 for ( const origKey of ObjectKeys ( opts . params ) ) {
793800 const key = + origKey ;
@@ -818,23 +825,23 @@ function Brotli(opts, mode) {
818825 throw new ERR_ZLIB_INITIALIZATION_FAILED ( ) ;
819826 }
820827
821- ZlibBase . call ( this , opts , mode , handle , brotliDefaultOpts ) ;
828+ ReflectApply ( ZlibBase , this , [ opts , mode , handle , brotliDefaultOpts ] ) ;
822829}
823830ObjectSetPrototypeOf ( Brotli . prototype , Zlib . prototype ) ;
824831ObjectSetPrototypeOf ( Brotli , Zlib ) ;
825832
826833function BrotliCompress ( opts ) {
827834 if ( ! ( this instanceof BrotliCompress ) )
828835 return new BrotliCompress ( opts ) ;
829- Brotli . call ( this , opts , BROTLI_ENCODE ) ;
836+ ReflectApply ( Brotli , this , [ opts , BROTLI_ENCODE ] ) ;
830837}
831838ObjectSetPrototypeOf ( BrotliCompress . prototype , Brotli . prototype ) ;
832839ObjectSetPrototypeOf ( BrotliCompress , Brotli ) ;
833840
834841function BrotliDecompress ( opts ) {
835842 if ( ! ( this instanceof BrotliDecompress ) )
836843 return new BrotliDecompress ( opts ) ;
837- Brotli . call ( this , opts , BROTLI_DECODE ) ;
844+ ReflectApply ( Brotli , this , [ opts , BROTLI_DECODE ] ) ;
838845}
839846ObjectSetPrototypeOf ( BrotliDecompress . prototype , Brotli . prototype ) ;
840847ObjectSetPrototypeOf ( BrotliDecompress , Brotli ) ;
0 commit comments