Skip to content

Commit

Permalink
stream: Fix eventNames() to not return not defined events
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasShabiCS committed Jan 1, 2024
1 parent 5fb6305 commit 34542ca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,11 @@ function listenerCount(type, listener) {
* @returns {any[]}
*/
EventEmitter.prototype.eventNames = function eventNames() {
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
const names = [];
for (const key of ReflectOwnKeys(this._events))
this._events[key] !== undefined && names.push(key);

return names;
};

function arrayClone(arr) {
Expand Down

0 comments on commit 34542ca

Please sign in to comment.