@@ -287,12 +287,6 @@ ObjectDefineProperty(EventEmitter, 'defaultMaxListeners', {
287
287
} ,
288
288
} ) ;
289
289
290
- function hasEventListener ( self , type ) {
291
- if ( type === undefined )
292
- return self . _events !== undefined ;
293
- return self . _events !== undefined && self . _events [ type ] !== undefined ;
294
- } ;
295
-
296
290
ObjectDefineProperties ( EventEmitter , {
297
291
kMaxEventTargetListeners : {
298
292
__proto__ : null ,
@@ -686,11 +680,13 @@ EventEmitter.prototype.removeListener =
686
680
function removeListener ( type , listener ) {
687
681
checkListener ( listener ) ;
688
682
689
- if ( ! hasEventListener ( this , type ) )
683
+ const events = this . _events ;
684
+ if ( events === undefined )
690
685
return this ;
691
686
692
- const events = this . _events ;
693
687
const list = events [ type ] ;
688
+ if ( list === undefined )
689
+ return this ;
694
690
695
691
if ( list === listener || list . listener === listener ) {
696
692
this . _eventsCount -= 1 ;
@@ -744,9 +740,9 @@ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
744
740
*/
745
741
EventEmitter . prototype . removeAllListeners =
746
742
function removeAllListeners ( type ) {
747
- if ( ! hasEventListener ( this ) )
748
- return this ;
749
743
const events = this . _events ;
744
+ if ( events === undefined )
745
+ return this ;
750
746
751
747
// Not listening for removeListener, no need to emit
752
748
if ( events . removeListener === undefined ) {
@@ -791,10 +787,14 @@ EventEmitter.prototype.removeAllListeners =
791
787
} ;
792
788
793
789
function _listeners ( target , type , unwrap ) {
794
- if ( ! hasEventListener ( target , type ) )
790
+ const events = target . _events ;
791
+
792
+ if ( events === undefined )
795
793
return [ ] ;
796
794
797
- const evlistener = target . _events [ type ] ;
795
+ const evlistener = events [ type ] ;
796
+ if ( evlistener === undefined )
797
+ return [ ] ;
798
798
799
799
if ( typeof evlistener === 'function' )
800
800
return unwrap ? [ evlistener . listener || evlistener ] : [ evlistener ] ;
0 commit comments