Skip to content

Commit

Permalink
events: make eventNames() use Reflect.ownKeys()
Browse files Browse the repository at this point in the history
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 Apr 21, 2016
1 parent cdba9a6 commit c1cd644
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down

0 comments on commit c1cd644

Please sign in to comment.