Skip to main content

Class: EventIterator<V>

An EventIterator, used for asynchronously iterating over received values.

Type parameters

Type parameter
V extends unknown[]

Implements

  • AsyncIterableIterator<V>

Constructors

new EventIterator()

new EventIterator<V>(emitter: EventEmitter<DefaultEventMap>, event: string, options: EventIteratorOptions<V>): EventIterator<V>

Parameters

ParameterTypeDescription
emitterEventEmitter<DefaultEventMap>The event emitter to listen to.
eventstringThe event we're listening for to receives values from.
optionsEventIteratorOptions<V>Any extra options.

Returns

EventIterator<V>

Source

index.ts:87

Properties

#ended

private #ended: boolean = false

Whether or not the EventIterator has ended.

Source

index.ts:50


#idle?

private optional #idle: number

The amount of idle time in ms before moving on.

Source

index.ts:55


#idleTimer

private #idleTimer: undefined | null | Timeout = null

The timer to track when this will idle out.

Source

index.ts:75


#limit

private #limit: number

The limit before ending the EventIterator.

Source

index.ts:70


#passed

private #passed: number = 0

The amount of events that have passed the filter.

Source

index.ts:65


#push()

private #push: (this: EventIterator<V>, ...value: V) => void

The push handler with context bound to the instance.

Parameters

ParameterType
thisEventIterator<V>
...valueV

Returns

void

Source

index.ts:80


#queue

private #queue: V[] = []

The queue of received values.

Source

index.ts:60


emitter

readonly emitter: EventEmitter<DefaultEventMap>

The emitter to listen to.

Source

index.ts:35


event

readonly event: string

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

Source

index.ts:40


filter

filter: EventIteratorFilter<V>

The filter used to filter out values.

Source

index.ts:45

Accessors

ended

get ended(): boolean

Whether or not the EventIterator has ended.

Returns

boolean

Source

index.ts:107

Methods

[asyncIterator]()

[asyncIterator](): AsyncIterableIterator<V>

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

Returns

AsyncIterableIterator<V>

Implementation of

AsyncIterableIterator.[asyncIterator]

Source

index.ts:184


end()

end(): void

Ends the EventIterator.

Returns

void

Source

index.ts:114


next()

next(): Promise<IteratorResult<V, any>>

The next value that's received from the EventEmitter.

Returns

Promise<IteratorResult<V, any>>

Implementation of

AsyncIterableIterator.next

Source

index.ts:127


push()

protected push(...value: V): void

Pushes a value into the queue.

Parameters

ParameterType
...valueV

Returns

void

Source

index.ts:191


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

Source

index.ts:168


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

Source

index.ts:176