mirror of https://github.com/nodejs/node.git
events: make eventNames() use Reflect.ownKeys()
Use `Reflect.ownKeys()` instead of `Object.keys()` and `Object.getOwnPropertySymbols()`. PR-URL: https://github.com/nodejs/node/pull/5822 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>pull/6266/merge
parent
cdba9a6c02
commit
c1cd64481f
|
@ -437,12 +437,7 @@ function listenerCount(type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EventEmitter.prototype.eventNames = function eventNames() {
|
EventEmitter.prototype.eventNames = function eventNames() {
|
||||||
if (this._eventsCount > 0) {
|
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
|
||||||
const events = this._events;
|
|
||||||
return Object.keys(events).concat(
|
|
||||||
Object.getOwnPropertySymbols(events));
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// About 1.5x faster than the two-arg version of Array#splice().
|
// About 1.5x faster than the two-arg version of Array#splice().
|
||||||
|
|
Loading…
Reference in New Issue