Skip to content

Commit c9628c5

Browse files
lpincajasnell
authored andcommitted
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>
1 parent 86ff844 commit c9628c5

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

lib/events.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,7 @@ function listenerCount(type) {
437437
}
438438

439439
EventEmitter.prototype.eventNames = function eventNames() {
440-
if (this._eventsCount > 0) {
441-
const events = this._events;
442-
return Object.keys(events).concat(
443-
Object.getOwnPropertySymbols(events));
444-
}
445-
return [];
440+
return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
446441
};
447442

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

0 commit comments

Comments
 (0)