// Returns a new Array with a function `onceWrapper` which has a property // `listener` which contains the original listener bound above constlisteners = emitter.rawListeners('log'); constlogFnWrapper = listeners[0];
// Logs "log once" to the console and does not unbind the `once` event logFnWrapper.listener();
// Logs "log once" to the console and removes the listener logFnWrapper();
emitter.on('log', () =>console.log('log persistently')); // Will return a new Array with a single function bound by `.on()` above constnewListeners = emitter.rawListeners('log');
Returns a copy of the array of listeners for the event named
eventName
, including any wrappers (such as those created by.once()
).