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
Luigi Pinca 2016-03-21 12:28:17 +01:00 committed by James M Snell
parent cdba9a6c02
commit c1cd64481f
1 changed files with 1 additions and 6 deletions

View File

@ -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().