Companion

external object Companion(source)

Properties

Link copied to clipboard

Value: boolean

Link copied to clipboard

Value: Symbol.for('nodejs.rejection')

Link copied to clipboard

By default, a maximum of 10 listeners can be registered for any single event. This limit can be changed for individual EventEmitter instances using the emitter.setMaxListeners(n) method. To change the default for allEventEmitter instances, the events.defaultMaxListeners property can be used. If this value is not a positive number, a RangeError is thrown.

Link copied to clipboard
external val errorMonitor: Symbol

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Functions

Link copied to clipboard
external fun addAbortListener(signal: AbortSignal, resource: (event: Event) -> Unit): Disposable

Listens once to the abort event on the provided signal.

Link copied to clipboard
external fun getEventListeners(emitter: EventTarget, type: EventType<*>): ReadonlyArray<Function<*>>

Returns a copy of the array of listeners for the event named eventName.

Link copied to clipboard
external fun getMaxListeners(emitter: EventEmitter): Double
external fun getMaxListeners(emitter: EventTarget): Double

Returns the currently set max amount of listeners.

Link copied to clipboard
external fun listenerCount(emitter: EventEmitter, type: EventType): Double

A class method that returns the number of listeners for the given eventName registered on the given emitter.

Link copied to clipboard
external fun <P : Tuple> on(emitter: EventEmitter, type: EventType, options: StaticEventEmitterOptions = definedExternally): AsyncIterator<P>
external fun <E : Event> on(emitter: EventTarget, type: EventType<E>, options: StaticEventEmitterOptions = definedExternally): AsyncIterator<Tuple1<E>>

Returns an AsyncIterator that iterates eventName events. It will throw if the EventEmitter emits 'error'. It removes all listeners when exiting the loop. The value returned by each iteration is an array composed of the emitted event arguments.

Link copied to clipboard
external fun <P : Tuple> once(emitter: EventEmitter, type: EventType, options: StaticEventEmitterOptions = definedExternally): Promise<P>
external fun <E : Event> once(emitter: EventTarget, type: EventType<E>, options: StaticEventEmitterOptions = definedExternally): Promise<Tuple1<E>>

Creates a Promise that is fulfilled when the EventEmitter emits the given event or that is rejected if the EventEmitter emits 'error' while waiting. The Promise will resolve with an array of all the arguments emitted to the given event.

Link copied to clipboard
external fun setMaxListeners(n: Number = definedExternally, vararg eventTargets: Any)