From 66518a0235e4608f49516af764329988c6c48468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 27 May 2015 10:19:33 +0200 Subject: [PATCH] add _events getter --- lib/events.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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;