2323
2424const {
2525 ArrayBuffer,
26- ArrayPrototypeForEach,
27- ArrayPrototypeMap,
28- ArrayPrototypePush,
29- FunctionPrototypeBind,
30- MathMaxApply,
26+ MathMax,
3127 NumberIsNaN,
3228 ObjectDefineProperties,
3329 ObjectDefineProperty,
30+ ObjectEntries,
3431 ObjectFreeze,
3532 ObjectKeys,
3633 ObjectSetPrototypeOf,
3734 ReflectApply,
38- StringPrototypeStartsWith,
3935 Symbol,
40- TypedArrayPrototypeFill,
4136 Uint32Array,
4237} = primordials ;
4338
@@ -130,10 +125,11 @@ function zlibBuffer(engine, buffer, callback) {
130125}
131126
132127function zlibBufferOnData ( chunk ) {
133- if ( ! this . buffers )
128+ if ( ! this . buffers ) {
134129 this . buffers = [ chunk ] ;
135- else
136- ArrayPrototypePush ( this . buffers , chunk ) ;
130+ } else {
131+ this . buffers . push ( chunk ) ;
132+ }
137133 this . nread += chunk . length ;
138134 if ( this . nread > this . _maxOutputLength ) {
139135 this . close ( ) ;
@@ -442,7 +438,7 @@ function processChunkSync(self, chunk, flushFlag) {
442438 if ( have > 0 ) {
443439 const out = buffer . slice ( offset , offset + have ) ;
444440 offset += have ;
445- ArrayPrototypePush ( buffers , out ) ;
441+ buffers . push ( out ) ;
446442 nread += out . byteLength ;
447443
448444 if ( nread > self . _maxOutputLength ) {
@@ -700,9 +696,10 @@ Zlib.prototype.params = function params(level, strategy, callback) {
700696 checkRangesOrGetDefault ( strategy , 'strategy' , Z_DEFAULT_STRATEGY , Z_FIXED ) ;
701697
702698 if ( this . _level !== level || this . _strategy !== strategy ) {
703- this . flush ( Z_SYNC_FLUSH ,
704- FunctionPrototypeBind ( paramsAfterFlushCallback , this ,
705- level , strategy , callback ) ) ;
699+ this . flush (
700+ Z_SYNC_FLUSH ,
701+ paramsAfterFlushCallback . bind ( this , level , strategy , callback ) ,
702+ ) ;
706703 } else {
707704 process . nextTick ( callback ) ;
708705 }
@@ -782,13 +779,10 @@ function createConvenienceMethod(ctor, sync) {
782779 } ;
783780}
784781
785- const kMaxBrotliParam = MathMaxApply ( ArrayPrototypeMap (
786- ObjectKeys ( constants ) ,
787- ( key ) => ( StringPrototypeStartsWith ( key , 'BROTLI_PARAM_' ) ?
788- constants [ key ] :
789- 0 ) ,
790- ) ) ;
791-
782+ const kMaxBrotliParam = MathMax (
783+ ...ObjectEntries ( constants )
784+ . map ( ( { 0 : key , 1 : value } ) => ( key . startsWith ( 'BROTLI_PARAM_' ) ? value : 0 ) ) ,
785+ ) ;
792786const brotliInitParamsArray = new Uint32Array ( kMaxBrotliParam + 1 ) ;
793787
794788const brotliDefaultOpts = {
@@ -799,9 +793,9 @@ const brotliDefaultOpts = {
799793function Brotli ( opts , mode ) {
800794 assert ( mode === BROTLI_DECODE || mode === BROTLI_ENCODE ) ;
801795
802- TypedArrayPrototypeFill ( brotliInitParamsArray , - 1 ) ;
796+ brotliInitParamsArray . fill ( - 1 ) ;
803797 if ( opts ?. params ) {
804- ArrayPrototypeForEach ( ObjectKeys ( opts . params ) , ( origKey ) => {
798+ ObjectKeys ( opts . params ) . forEach ( ( origKey ) => {
805799 const key = + origKey ;
806800 if ( NumberIsNaN ( key ) || key < 0 || key > kMaxBrotliParam ||
807801 ( brotliInitParamsArray [ key ] | 0 ) !== - 1 ) {
@@ -939,10 +933,12 @@ ObjectDefineProperties(module.exports, {
939933
940934// These should be considered deprecated
941935// expose all the zlib constants
942- for ( const bkey of ObjectKeys ( constants ) ) {
943- if ( StringPrototypeStartsWith ( bkey , 'BROTLI' ) ) continue ;
944- ObjectDefineProperty ( module . exports , bkey , {
936+ for ( const { 0 : key , 1 : value } of ObjectEntries ( constants ) ) {
937+ if ( key . startsWith ( 'BROTLI' ) ) continue ;
938+ ObjectDefineProperty ( module . exports , key , {
945939 __proto__ : null ,
946- enumerable : false , value : constants [ bkey ] , writable : false ,
940+ enumerable : false ,
941+ value,
942+ writable : false ,
947943 } ) ;
948944}
0 commit comments