mirror of https://github.com/lukechilds/node.git
Browse Source
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>v4.0.0-rc
Sakthipriyan Vairamani
10 years ago
13 changed files with 56 additions and 30 deletions
@ -0,0 +1,18 @@ |
|||
'use strict'; |
|||
|
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
const EventEmitter = require('events'); |
|||
|
|||
const emitter = new EventEmitter(); |
|||
emitter.on('foo', function() {}); |
|||
emitter.on('foo', function() {}); |
|||
emitter.on('baz', function() {}); |
|||
// Allow any type
|
|||
emitter.on(123, function() {}); |
|||
|
|||
assert.strictEqual(EventEmitter.listenerCount(emitter, 'foo'), 2); |
|||
assert.strictEqual(emitter.listenerCount('foo'), 2); |
|||
assert.strictEqual(emitter.listenerCount('bar'), 0); |
|||
assert.strictEqual(emitter.listenerCount('baz'), 1); |
|||
assert.strictEqual(emitter.listenerCount(123), 1); |
Loading…
Reference in new issue