Skip to main content

Class: EventIterator<V>

@sapphire/event-iterator.EventIterator

An EventIterator, used for asynchronously iterating over received values.

Type parameters

NameType
Vextends unknown[]

Implements

  • AsyncIterableIterator<V>

Constructors

constructor

โ€ข new EventIterator<V>(emitter, event, options?)

Type parameters

NameType
Vextends unknown[]

Parameters

NameTypeDescription
emitterEventEmitterThe event emitter to listen to.
eventstringThe event we're listening for to receives values from.
optionsEventIteratorOptions<V>Any extra options.

Defined in

projects/utilities/packages/event-iterator/src/index.ts:89

Properties

#ended

โ€ข Private #ended: boolean = false

Whether or not the EventIterator has ended.

Defined in

projects/utilities/packages/event-iterator/src/index.ts:51


#idle

โ€ข Private Optional #idle: number

The amount of idle time in ms before moving on.

Defined in

projects/utilities/packages/event-iterator/src/index.ts:56


#idleTimer

โ€ข Private #idleTimer: null | Timer = null

The timer to track when this will idle out.

Defined in

projects/utilities/packages/event-iterator/src/index.ts:76


#limit

โ€ข Private #limit: number

The limit before ending the EventIterator.

Defined in

projects/utilities/packages/event-iterator/src/index.ts:71


#passed

โ€ข Private #passed: number = 0

The amount of events that have passed the filter.

Defined in

projects/utilities/packages/event-iterator/src/index.ts:66


#push

โ€ข Private #push: (...value: V) => void

Type declaration

โ–ธ (...value): void

The push handler with context bound to the instance.

Parameters
NameType
...valueV
Returns

void

Defined in

projects/utilities/packages/event-iterator/src/index.ts:81


#queue

โ€ข Private #queue: V[] = []

The queue of received values.

Defined in

projects/utilities/packages/event-iterator/src/index.ts:61


emitter

โ€ข Readonly emitter: EventEmitter

The emitter to listen to.

Defined in

projects/utilities/packages/event-iterator/src/index.ts:36


event

โ€ข Readonly event: string

The event the event iterator is listening for to receive values from.

Defined in

projects/utilities/packages/event-iterator/src/index.ts:41


filter

โ€ข filter: EventIteratorFilter<V>

The filter used to filter out values.

Defined in

projects/utilities/packages/event-iterator/src/index.ts:46

Accessors

ended

โ€ข get ended(): boolean

Whether or not the EventIterator has ended.

Returns

boolean

Defined in

projects/utilities/packages/event-iterator/src/index.ts:111

Methods

[asyncIterator]

โ–ธ [asyncIterator](): AsyncIterableIterator<V>

The symbol allowing EventIterators to be used in for-await-of loops.

Returns

AsyncIterableIterator<V>

Implementation of

AsyncIterableIterator.__@asyncIterator@384514

Defined in

projects/utilities/packages/event-iterator/src/index.ts:189


end

โ–ธ end(): void

Ends the EventIterator.

Returns

void

Defined in

projects/utilities/packages/event-iterator/src/index.ts:118


next

โ–ธ next(): Promise<IteratorResult<V, any>>

The next value that's received from the EventEmitter.

Returns

Promise<IteratorResult<V, any>>

Implementation of

AsyncIterableIterator.next

Defined in

projects/utilities/packages/event-iterator/src/index.ts:132


push

โ–ธ Protected push(...value): void

Pushes a value into the queue.

Parameters

NameType
...valueV

Returns

void

Defined in

projects/utilities/packages/event-iterator/src/index.ts:196


return

โ–ธ return(): Promise<IteratorResult<V, any>>

Handles what happens when you break or return from a loop.

Returns

Promise<IteratorResult<V, any>>

Implementation of

AsyncIterableIterator.return

Defined in

projects/utilities/packages/event-iterator/src/index.ts:173


throw

โ–ธ throw(): Promise<IteratorResult<V, any>>

Handles what happens when you encounter an error in a loop.

Returns

Promise<IteratorResult<V, any>>

Implementation of

AsyncIterableIterator.throw

Defined in

projects/utilities/packages/event-iterator/src/index.ts:181