Skip to content
Permalink
Browse files

events: remove unreachable code

Commit 8d386ed stopped the
Event Emitter implementation from storing arrays containing a
single listener. This change left a section of code in
removeListener() as unreachable. This commit removes the
unreachable code.

Refs: #12043
PR-URL: #12501
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
cjihrig committed Apr 19, 2017
1 parent 1159a71 commit 58066d16d56ea58d4139bc865349fec9346b12ba
Showing with 5 additions and 14 deletions.
  1. +5 −14 lib/events.js
@@ -374,22 +374,13 @@ EventEmitter.prototype.removeListener =
if (position < 0)
return this;

if (list.length === 1) {
if (--this._eventsCount === 0) {
this._events = Object.create(null);
return this;
} else {
delete events[type];
}
} else if (position === 0) {
if (position === 0)
list.shift();
if (list.length === 1)
events[type] = list[0];
} else {
else
spliceOne(list, position);
if (list.length === 1)
events[type] = list[0];
}

if (list.length === 1)
events[type] = list[0];

if (events.removeListener)
this.emit('removeListener', type, originalListener || listener);

0 comments on commit 58066d1

Please sign in to comment.
You can’t perform that action at this time.