Skip to content

Commit bf229ca

Browse files
committed
stream: fix eventNames() to not return not defined events
1 parent 5fb6305 commit bf229ca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/events.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,11 @@ function listenerCount(type, listener) {
888888
* @returns {any[]}
889889
*/
890890
EventEmitter.prototype.eventNames = function eventNames() {
891-
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
891+
const names = [];
892+
for (const key of ReflectOwnKeys(this._events))
893+
this._events[key] !== undefined && names.push(key);
894+
895+
return names;
892896
};
893897

894898
function arrayClone(arr) {

0 commit comments

Comments
 (0)