events: handle inherited properties properly
requested to merge github/fork/thefourtheye/fix-for-event-listener-and-inherited-properties into master
As of now, the events module considers inherited properties as one of the valid types, by default.
> process.version
'v3.0.0'
> events.EventEmitter.listenerCount(new events.EventEmitter(), 'toString')
1
This patch makes sure that the inherited properties are considered as normal types and they will not be counted unless explicitly added.
> process.version
'v4.0.0-pre'
> events.EventEmitter.listenerCount(new events.EventEmitter(), 'toString')
0
> const emitter = new events.EventEmitter();
undefined
> emitter.on('toString', function() {});
EventEmitter {
domain:
Domain {
domain: null,
_events: { error: [Function] },
_eventsCount: 1,
_maxListeners: undefined,
members: [] },
_events: { toString: [Function] },
_eventsCount: 1,
_maxListeners: undefined }
> events.EventEmitter.listenerCount(emitter, 'toString')
1
I am guessing this would be a semver-major
change, as this could be a breaking change.