2222'use strict' ;
2323
2424const {
25- ArrayPrototypeForEach,
26- ArrayPrototypePush,
2725 ArrayPrototypeSlice,
2826 Boolean,
2927 Error,
3028 ErrorCaptureStackTrace,
31- FunctionPrototypeCall,
3229 MathMin,
3330 NumberIsNaN,
3431 ObjectCreate,
@@ -39,7 +36,6 @@ const {
3936 Promise,
4037 PromiseReject,
4138 PromiseResolve,
42- ReflectApply,
4339 ReflectOwnKeys,
4440 String,
4541 Symbol,
@@ -84,7 +80,7 @@ const lazyDOMException = hideStackFrames((message, name) => {
8480
8581
8682function EventEmitter ( opts ) {
87- FunctionPrototypeCall ( EventEmitter . init , this , opts ) ;
83+ EventEmitter . init . call ( this , opts ) ;
8884}
8985module . exports = EventEmitter ;
9086module . exports . once = once ;
@@ -175,8 +171,8 @@ EventEmitter.setMaxListeners =
175171 if ( isEventTarget === undefined )
176172 isEventTarget = require ( 'internal/event_target' ) . isEventTarget ;
177173
178- // Performance for forEach is now comparable with regular for-loop
179- ArrayPrototypeForEach ( eventTargets , ( target ) => {
174+ for ( let i = 0 ; i < eventTargets . length ; i ++ ) {
175+ const target = eventTargets [ i ] ;
180176 if ( isEventTarget ( target ) ) {
181177 target [ kMaxEventTargetListeners ] = n ;
182178 target [ kMaxEventTargetListenersWarned ] = false ;
@@ -188,7 +184,7 @@ EventEmitter.setMaxListeners =
188184 [ 'EventEmitter' , 'EventTarget' ] ,
189185 target ) ;
190186 }
191- } ) ;
187+ }
192188 }
193189 } ;
194190
@@ -227,7 +223,7 @@ function addCatch(that, promise, type, args) {
227223 const then = promise . then ;
228224
229225 if ( typeof then === 'function' ) {
230- FunctionPrototypeCall ( then , promise , undefined , function ( err ) {
226+ then . call ( promise , undefined , function ( err ) {
231227 // The callback is called with nextTick to avoid a follow-up
232228 // rejection from this promise.
233229 process . nextTick ( emitUnhandledRejectionOrErr , that , err , type , args ) ;
@@ -376,7 +372,7 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
376372 return false ;
377373
378374 if ( typeof handler === 'function' ) {
379- const result = ReflectApply ( handler , this , args ) ;
375+ const result = handler . apply ( this , args ) ;
380376
381377 // We check if result is undefined first because that
382378 // is the most common case so we do not pay any perf
@@ -388,7 +384,7 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
388384 const len = handler . length ;
389385 const listeners = arrayClone ( handler ) ;
390386 for ( let i = 0 ; i < len ; ++ i ) {
391- const result = ReflectApply ( listeners [ i ] , this , args ) ;
387+ const result = listeners [ i ] . apply ( this , args ) ;
392388
393389 // We check if result is undefined first because that
394390 // is the most common case so we do not pay any perf
@@ -698,7 +694,7 @@ function getEventListeners(emitterOrTarget, type) {
698694 const listeners = [ ] ;
699695 let handler = root ?. next ;
700696 while ( handler ?. listener !== undefined ) {
701- ArrayPrototypePush ( listeners , handler . listener ) ;
697+ listeners . push ( handler . listener ) ;
702698 handler = handler . next ;
703699 }
704700 return listeners ;
@@ -842,7 +838,7 @@ function on(emitter, event, options) {
842838
843839 // Wait until an event happens
844840 return new Promise ( function ( resolve , reject ) {
845- ArrayPrototypePush ( unconsumedPromises , { resolve, reject } ) ;
841+ unconsumedPromises . push ( { resolve, reject } ) ;
846842 } ) ;
847843 } ,
848844
@@ -906,7 +902,7 @@ function on(emitter, event, options) {
906902 if ( promise ) {
907903 promise . resolve ( createIterResult ( args , false ) ) ;
908904 } else {
909- ArrayPrototypePush ( unconsumedEvents , args ) ;
905+ unconsumedEvents . push ( args ) ;
910906 }
911907 }
912908
0 commit comments