|
22 | 22 | 'use strict'; |
23 | 23 |
|
24 | 24 | const { |
| 25 | + ArrayPrototypeForEach, |
25 | 26 | ArrayPrototypePush, |
| 27 | + ArrayPrototypeSlice, |
26 | 28 | Boolean, |
27 | 29 | Error, |
28 | 30 | ErrorCaptureStackTrace, |
| 31 | + FunctionPrototypeCall, |
29 | 32 | MathMin, |
30 | 33 | NumberIsNaN, |
31 | 34 | ObjectCreate, |
@@ -81,7 +84,7 @@ const lazyDOMException = hideStackFrames((message, name) => { |
81 | 84 |
|
82 | 85 |
|
83 | 86 | function EventEmitter(opts) { |
84 | | - EventEmitter.init.call(this, opts); |
| 87 | + FunctionPrototypeCall(EventEmitter.init, this, opts); |
85 | 88 | } |
86 | 89 | module.exports = EventEmitter; |
87 | 90 | module.exports.once = once; |
@@ -173,7 +176,7 @@ EventEmitter.setMaxListeners = |
173 | 176 | isEventTarget = require('internal/event_target').isEventTarget; |
174 | 177 |
|
175 | 178 | // Performance for forEach is now comparable with regular for-loop |
176 | | - eventTargets.forEach((target) => { |
| 179 | + ArrayPrototypeForEach(eventTargets, (target) => { |
177 | 180 | if (isEventTarget(target)) { |
178 | 181 | target[kMaxEventTargetListeners] = n; |
179 | 182 | target[kMaxEventTargetListenersWarned] = false; |
@@ -224,7 +227,7 @@ function addCatch(that, promise, type, args) { |
224 | 227 | const then = promise.then; |
225 | 228 |
|
226 | 229 | if (typeof then === 'function') { |
227 | | - then.call(promise, undefined, function(err) { |
| 230 | + FunctionPrototypeCall(then, promise, undefined, function(err) { |
228 | 231 | // The callback is called with nextTick to avoid a follow-up |
229 | 232 | // rejection from this promise. |
230 | 233 | process.nextTick(emitUnhandledRejectionOrErr, that, err, type, args); |
@@ -670,7 +673,7 @@ function arrayClone(arr) { |
670 | 673 | case 5: return [arr[0], arr[1], arr[2], arr[3], arr[4]]; |
671 | 674 | case 6: return [arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]]; |
672 | 675 | } |
673 | | - return arr.slice(); |
| 676 | + return ArrayPrototypeSlice(arr); |
674 | 677 | } |
675 | 678 |
|
676 | 679 | function unwrapListeners(arr) { |
@@ -839,7 +842,7 @@ function on(emitter, event, options) { |
839 | 842 |
|
840 | 843 | // Wait until an event happens |
841 | 844 | return new Promise(function(resolve, reject) { |
842 | | - unconsumedPromises.push({ resolve, reject }); |
| 845 | + ArrayPrototypePush(unconsumedPromises, { resolve, reject }); |
843 | 846 | }); |
844 | 847 | }, |
845 | 848 |
|
@@ -903,7 +906,7 @@ function on(emitter, event, options) { |
903 | 906 | if (promise) { |
904 | 907 | promise.resolve(createIterResult(args, false)); |
905 | 908 | } else { |
906 | | - unconsumedEvents.push(args); |
| 909 | + ArrayPrototypePush(unconsumedEvents, args); |
907 | 910 | } |
908 | 911 | } |
909 | 912 |
|
|
0 commit comments