|
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) {
|
@@ -813,7 +816,7 @@ function on(emitter, event, options) {
|
813 | 816 |
|
814 | 817 | // Wait until an event happens
|
815 | 818 | return new Promise(function(resolve, reject) {
|
816 |
| - unconsumedPromises.push({ resolve, reject }); |
| 819 | + ArrayPrototypePush(unconsumedPromises, { resolve, reject }); |
817 | 820 | });
|
818 | 821 | },
|
819 | 822 |
|
@@ -877,7 +880,7 @@ function on(emitter, event, options) {
|
877 | 880 | if (promise) {
|
878 | 881 | promise.resolve(createIterResult(args, false));
|
879 | 882 | } else {
|
880 |
| - unconsumedEvents.push(args); |
| 883 | + ArrayPrototypePush(unconsumedEvents, args); |
881 | 884 | }
|
882 | 885 | }
|
883 | 886 |
|
|
0 commit comments