Skip to content

Commit

Permalink
events: remove unneeded safety check code
Browse files Browse the repository at this point in the history
In the process of creating nodejs#9865, it was discovered that the code
checking whether or not events was defined was unnecessary because
the only situation in which events would be undefined is if it is
monkeypatched by an external entity. This should be removed in order
to discourage this. If the test added in nodejs#9865 is merged, it will
need to removed on merge of this commit.
  • Loading branch information
captainsafia committed Dec 1, 2016
1 parent 330e63c commit 46ea5b6
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,17 +423,13 @@ EventEmitter.prototype.listeners = function listeners(type) {
var ret;
var events = this._events;

if (!events)
evlistener = events[type];
if (!evlistener)
ret = [];
else {
evlistener = events[type];
if (!evlistener)
ret = [];
else if (typeof evlistener === 'function')
ret = [evlistener.listener || evlistener];
else
ret = unwrapListeners(evlistener);
}
else if (typeof evlistener === 'function')
ret = [evlistener.listener || evlistener];
else
ret = unwrapListeners(evlistener);

return ret;
};
Expand Down

0 comments on commit 46ea5b6

Please sign in to comment.