Method description:
All listeners registered for the specified event will be returned as an array.
Grammar:
emitter.listeners(event)
Receive parameters:
event Specified event
Example:
server.on('connection', function (stream) {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// [[Function] ]
Source code:
EventEmitter.prototype.listeners = function(type) {
var ret;
if (!this._events || !this._events[type])
ret = [];
else if (util.isFunction(this._events[type]))
ret = [this._events[type]];
else
ret = this._events[type].slice();
Return ret;
};