Method description:
All listeners registered with the specified event will be returned as an array.
grammar:
The code copy is as follows:
emitter.listeners(event)
Receive parameters:
event Specify event
example:
The code copy is as follows:
server.on('connection', function (stream) {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// [ [Function] ]
Source code:
The code copy is as follows:
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 return return;
};