events: deprecate static listenerCount function

As per the discussion in #734, this patch deprecates the usage of
`EventEmitter.listenerCount` static function in the docs, and introduces
the `listenerCount` function in the prototype of `EventEmitter` itself.

PR-URL: https://github.com/nodejs/node/pull/2349
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
This commit is contained in:
Sakthipriyan Vairamani authored and Rod Vagg committed 2015-08-20 20:49:36 +10:00
1 parent 8576324cea
commit 3e6a6fcdd6
13 files changed
+56 -30

No files matched your search

+1 -2
View File
@@ -802,8 +802,7 @@
});
process.on('removeListener', function(type, listener) {
if (signalWraps.hasOwnProperty(type) &&
NativeModule.require('events').listenerCount(this, type) === 0) {
if (signalWraps.hasOwnProperty(type) && this.listenerCount(type) === 0) {
signalWraps[type].close();
delete signalWraps[type];
}