primus / eventemitter3

EventEmitter3 - Because there's also a number 2. And we're faster.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

evt listener count judgement by `handlers.fn` may got wrong results

SunGuoQiang123 opened this issue · comments

if someone makes some changes like Array.prototype.fn = function() {} , then the judgement for the event listener count may get wrong results when the event have more than one listeners

Array.prototype.fn = function() {};
const em = new EventEmitter();
em.on('test', a => a);
em.on('test', a => console.log(a));
console.log(em.listenerCount('test'));

not sure if this is necessary because this is very rare to happen, if so, just close this issue

Yes, I don't think this is a problem. Changing the prototype of standard, built-in objects, is not common and recommended.