| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4e5818a commit 0285aa0
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,8 +21,21 @@ | |||
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | - const { Math, Object, Reflect } = primordials; | ||
| 25 | - const apply = Reflect.apply; | ||
| 24 | + const { | ||
| 25 | + Math: { | ||
| 26 | + min: MathMin | ||
| 27 | + }, | ||
| 28 | + Object: { | ||
| 29 | + defineProperty: ObjectDefineProperty, | ||
| 30 | + getPrototypeOf: ObjectGetPrototypeOf, | ||
| 31 | + create: ObjectCreate, | ||
| 32 | + keys: ObjectKeys, | ||
| 33 | + }, | ||
| 34 | + Reflect: { | ||
| 35 | + apply: ReflectApply, | ||
| 36 | + ownKeys: ReflectOwnKeys, | ||
| 37 | + } | ||
| 38 | + } = primordials; | ||
| 26 | 39 | ||
| 27 | 40 | var spliceOne; | |
| 28 | 41 | ||
@@ -65,7 +78,7 @@ function checkListener(listener) { | |||
| 65 | 78 | } | |
| 66 | 79 | } | |
| 67 | 80 | ||
| 68 | - Object.defineProperty(EventEmitter, 'defaultMaxListeners', { | ||
| 81 | + ObjectDefineProperty(EventEmitter, 'defaultMaxListeners', { | ||
| 69 | 82 | enumerable: true, | |
| 70 | 83 | get: function() { | |
| 71 | 84 | return defaultMaxListeners; | |
@@ -83,8 +96,8 @@ Object.defineProperty(EventEmitter, 'defaultMaxListeners', { | |||
| 83 | 96 | EventEmitter.init = function() { | |
| 84 | 97 | ||
| 85 | 98 | if (this._events === undefined || | |
| 86 | - this._events === Object.getPrototypeOf(this)._events) { | ||
| 87 | - this._events = Object.create(null); | ||
| 99 | + this._events === ObjectGetPrototypeOf(this)._events) { | ||
| 100 | + this._events = ObjectCreate(null); | ||
| 88 | 101 | this._eventsCount = 0; | |
| 89 | 102 | } | |
| 90 | 103 | ||
@@ -121,7 +134,7 @@ function identicalSequenceRange(a, b) { | |||
| 121 | 134 | const rest = b.length - pos; | |
| 122 | 135 | if (rest > 3) { | |
| 123 | 136 | let len = 1; | |
| 124 | - const maxLen = Math.min(a.length - i, rest); | ||
| 137 | + const maxLen = MathMin(a.length - i, rest); | ||
| 125 | 138 | // Count the number of consecutive entries. | |
| 126 | 139 | while (maxLen > len && a[i + len] === b[pos + len]) { | |
| 127 | 140 | len++; | |
@@ -176,7 +189,7 @@ EventEmitter.prototype.emit = function emit(type, ...args) { | |||
| 176 | 189 | const capture = {}; | |
| 177 | 190 | // eslint-disable-next-line no-restricted-syntax | |
| 178 | 191 | Error.captureStackTrace(capture, EventEmitter.prototype.emit); | |
| 179 | - Object.defineProperty(er, kEnhanceStackBeforeInspector, { | ||
| 192 | + ObjectDefineProperty(er, kEnhanceStackBeforeInspector, { | ||
| 180 | 193 | value: enhanceStackTrace.bind(this, er, capture), | |
| 181 | 194 | configurable: true | |
| 182 | 195 | }); | |
@@ -207,12 +220,12 @@ EventEmitter.prototype.emit = function emit(type, ...args) { | |||
| 207 | 220 | return false; | |
| 208 | 221 | ||
| 209 | 222 | if (typeof handler === 'function') { | |
| 210 | - apply(handler, this, args); | ||
| 223 | + ReflectApply(handler, this, args); | ||
| 211 | 224 | } else { | |
| 212 | 225 | const len = handler.length; | |
| 213 | 226 | const listeners = arrayClone(handler, len); | |
| 214 | 227 | for (var i = 0; i < len; ++i) | |
| 215 | - apply(listeners[i], this, args); | ||
| 228 | + ReflectApply(listeners[i], this, args); | ||
| 216 | 229 | } | |
| 217 | 230 | ||
| 218 | 231 | return true; | |
@@ -227,7 +240,7 @@ function _addListener(target, type, listener, prepend) { | |||
| 227 | 240 | ||
| 228 | 241 | events = target._events; | |
| 229 | 242 | if (events === undefined) { | |
| 230 | - events = target._events = Object.create(null); | ||
| 243 | + events = target._events = ObjectCreate(null); | ||
| 231 | 244 | target._eventsCount = 0; | |
| 232 | 245 | } else { | |
| 233 | 246 | // To avoid recursion in the case that type === "newListener"! Before | |
@@ -341,7 +354,7 @@ EventEmitter.prototype.removeListener = | |||
| 341 | 354 | ||
| 342 | 355 | if (list === listener || list.listener === listener) { | |
| 343 | 356 | if (--this._eventsCount === 0) | |
| 344 | - this._events = Object.create(null); | ||
| 357 | + this._events = ObjectCreate(null); | ||
| 345 | 358 | else { | |
| 346 | 359 | delete events[type]; | |
| 347 | 360 | if (events.removeListener) | |
@@ -390,11 +403,11 @@ EventEmitter.prototype.removeAllListeners = | |||
| 390 | 403 | // Not listening for removeListener, no need to emit | |
| 391 | 404 | if (events.removeListener === undefined) { | |
| 392 | 405 | if (arguments.length === 0) { | |
| 393 | - this._events = Object.create(null); | ||
| 406 | + this._events = ObjectCreate(null); | ||
| 394 | 407 | this._eventsCount = 0; | |
| 395 | 408 | } else if (events[type] !== undefined) { | |
| 396 | 409 | if (--this._eventsCount === 0) | |
| 397 | - this._events = Object.create(null); | ||
| 410 | + this._events = ObjectCreate(null); | ||
| 398 | 411 | else | |
| 399 | 412 | delete events[type]; | |
| 400 | 413 | } | |
@@ -403,12 +416,12 @@ EventEmitter.prototype.removeAllListeners = | |||
| 403 | 416 | ||
| 404 | 417 | // Emit removeListener for all listeners on all events | |
| 405 | 418 | if (arguments.length === 0) { | |
| 406 | - for (const key of Object.keys(events)) { | ||
| 419 | + for (const key of ObjectKeys(events)) { | ||
| 407 | 420 | if (key === 'removeListener') continue; | |
| 408 | 421 | this.removeAllListeners(key); | |
| 409 | 422 | } | |
| 410 | 423 | this.removeAllListeners('removeListener'); | |
| 411 | - this._events = Object.create(null); | ||
| 424 | + this._events = ObjectCreate(null); | ||
| 412 | 425 | this._eventsCount = 0; | |
| 413 | 426 | return this; | |
| 414 | 427 | } | |
@@ -478,7 +491,7 @@ function listenerCount(type) { | |||
| 478 | 491 | } | |
| 479 | 492 | ||
| 480 | 493 | EventEmitter.prototype.eventNames = function eventNames() { | |
| 481 | - return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : []; | ||
| 494 | + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; | ||
| 482 | 495 | }; | |
| 483 | 496 | ||
| 484 | 497 | function arrayClone(arr, n) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments