Skip to content
Permalink
Browse files

events: make eventNames() use Reflect.ownKeys()

Use `Reflect.ownKeys()` instead of `Object.keys()` and
`Object.getOwnPropertySymbols()`.

PR-URL: #5822
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
lpinca authored and jasnell committed Mar 21, 2016
1 parent cdba9a6 commit c1cd64481ff8801c8c400c99de9a5f2618dae5ea
Showing with 1 addition and 6 deletions.
  1. +1 −6 lib/events.js
@@ -437,12 +437,7 @@ function listenerCount(type) {
}

EventEmitter.prototype.eventNames = function eventNames() {
if (this._eventsCount > 0) {
const events = this._events;
return Object.keys(events).concat(
Object.getOwnPropertySymbols(events));
}
return [];
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
};

// About 1.5x faster than the two-arg version of Array#splice().

0 comments on commit c1cd644

Please sign in to comment.
You can’t perform that action at this time.