Example #1
0
emitter.once(1, listener4);

emitter.prependListener('send', listener5);

emitter.prependOnceListener('send', listener6);

emitter.listeners('send');
emitter.listenerCount('send');
emitter.rawListeners('send');

EventEmitter.defaultMaxListeners = 100;
console.log(`count(static): ${EventEmitter.listenerCount(emitter, 'send')}`);
console.log(`ncount: ${emitter.listenerCount('send')}`);
console.log(`maxListeners: ${emitter.getMaxListeners()}`);
console.log(`eventNames: ${emitter.eventNames().join(', ')}`);
console.log(`rawListeners count: ${emitter.rawListeners('send').length}`);

setTimeout(() => {
  console.log('\n');
  emitter.emit('send');
}, 1000);

setTimeout(() => {
  console.log('\n');
  emitter.emit('send');
  emitter.removeListener('send', listener2);
}, 2000);

setTimeout(() => {
  console.log('\n');
Example #2
0
    result = emitter.listeners(event);
}

{
    let result: boolean;

    result = emitter.emit(event);
    result = emitter.emit(event, any);
    result = emitter.emit(event, any, any);
    result = emitter.emit(event, any, any, any);
}

{
    let result: Array<string | symbol>;

    result = emitter.eventNames();
}

{
    class Networker extends events.EventEmitter {
        constructor() {
            super();

            this.emit("mingling");
        }
    }
}

{
    new events();
}