diff --git a/lib/events.js b/lib/events.js index 8ee587e87c5ff5..bd6a36866187e5 100644 --- a/lib/events.js +++ b/lib/events.js @@ -481,23 +481,19 @@ EventEmitter.prototype.removeAllListeners = }; EventEmitter.prototype.listeners = function listeners(type) { - var evlistener; - var ret; - var events = this._events; + const events = this._events; if (events === undefined) - ret = []; - else { - evlistener = events[type]; - if (evlistener === undefined) - ret = []; - else if (typeof evlistener === 'function') - ret = [evlistener.listener || evlistener]; - else - ret = unwrapListeners(evlistener); - } + return []; - return ret; + const evlistener = events[type]; + if (evlistener === undefined) + return []; + + if (typeof evlistener === 'function') + return [evlistener.listener || evlistener]; + + return unwrapListeners(evlistener); }; EventEmitter.listenerCount = function(emitter, type) {