import type { EventEmitterListener, EventEmitterListenerOptions } from '../definitions/interfaces.js'; import type { EventEmitterEvents, KeyOf } from '../definitions/types.js'; /** * The EventEmitter class is used to emit events and register listeners. * The API is based on the Node.js EventEmitter API. * * [Aracna Reference](https://aracna.dariosechi.it/core/classes/event-emitter) */ export declare class EventEmitter { protected listeners: EventEmitterListener[]; protected maxListeners: number; constructor(); /** * Counts the listeners that match the name, callback and options. * If no arguments are passed, all listeners will be counted. */ countListeners(name?: K, callback?: T[K], options?: EventEmitterListenerOptions): number; /** * Emits an event. */ emit(name: K, ...args: Parameters): boolean; /** * Returns the names of the events that have listeners. */ getEventNames(): KeyOf.Shallow[]; /** * Returns the listeners that match the name, callback and options. * If no arguments are passed, all listeners will be returned. */ getListeners(name?: K, callback?: T[K], options?: EventEmitterListenerOptions): EventEmitterListener[]; /** * Returns the maximum number of listeners that can be registered for a single event. */ getMaxListeners(): number; /** * Checks if the event has listeners that match the name, callback and options. */ hasListeners(name?: K, callback?: T[K], options?: EventEmitterListenerOptions): boolean; /** * Removes the listeners that match the name, callback and options. * If no arguments are passed, all listeners will be removed. */ off(name?: K, callback?: T[K], options?: EventEmitterListenerOptions): this; /** * Adds a listener, which will be called when the event is emitted. * * Optionally the listener can be removed after the first call with the `once` option. * Optionally the listener can be prepended to the listeners array with the `prepend` option. */ on(name: K, callback: T[K], options?: EventEmitterListenerOptions): this; /** * Adds a listener, which will be called only once when the event is emitted. */ once(name: K, callback: T[K], options?: EventEmitterListenerOptions): this; /** * Adds a listener, which will be called first when the event is emitted. */ prepend(name: K, callback: T[K], options?: EventEmitterListenerOptions): this; /** * Sets the listeners. */ setListeners(listeners: EventEmitterListener[]): this; /** * Sets the maximum number of listeners that can be registered for a single event. */ setMaxListeners(n: number): this; }