mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
events: remove unreachable code
Commit 8d386ed7e1 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: https://github.com/nodejs/node/pull/12043
PR-URL: https://github.com/nodejs/node/pull/12501
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user