Skip to content

Commit 2ce6916

Browse files
cjihrigMylesBorins
authored andcommitted
events: remove unnecessary checks
This commit removes two truthy checks for object properties that are immediately followed by a strict equality check. The other item in the comparison is guaranteed to be a function by this point in the code, so the truthy check is redundant. PR-URL: #9330 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 912cae6 commit 2ce6916

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/events.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ EventEmitter.prototype.removeListener =
326326
if (!list)
327327
return this;
328328

329-
if (list === listener || (list.listener && list.listener === listener)) {
329+
if (list === listener || list.listener === listener) {
330330
if (--this._eventsCount === 0)
331331
this._events = new EventHandlers();
332332
else {
@@ -338,8 +338,7 @@ EventEmitter.prototype.removeListener =
338338
position = -1;
339339

340340
for (i = list.length; i-- > 0;) {
341-
if (list[i] === listener ||
342-
(list[i].listener && list[i].listener === listener)) {
341+
if (list[i] === listener || list[i].listener === listener) {
343342
originalListener = list[i].listener;
344343
position = i;
345344
break;

0 commit comments

Comments
 (0)