diff --git a/lib/events.js b/lib/events.js index 59a56c2541523a..2860447a749d50 100644 --- a/lib/events.js +++ b/lib/events.js @@ -377,6 +377,20 @@ EventEmitter.prototype.listeners = function listeners(type) { return ret; }; +Object.defineProperty(EventEmitter.prototype, '_events', { + get() { + const thisEvents = this[eventSymbol]; + if (!thisEvents) + return; + + const events = {}; + for (let event of thisEvents.entries()) { + events[event[0]] = event[1]; + } + return events; + } +}); + EventEmitter.listenerCount = function(emitter, type) { var evlistener; var ret = 0;