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>

Defined in

index.ts:87

Properties

#ended

private #ended: boolean = false

Whether or not the EventIterator has ended.

Defined in

index.ts:50


#idle?

private readonly optional #idle: number

The amount of idle time in ms before moving on.

Defined in

index.ts:55


#idleTimer

private readonly #idleTimer: undefined | null | Timeout = null

The timer to track when this will idle out.

Defined in

index.ts:75


#limit

private readonly #limit: number

The limit before ending the EventIterator.

Defined in

index.ts:70


#passed

private #passed: number = 0

The amount of events that have passed the filter.

Defined in

index.ts:65


#push()

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

The push handler with context bound to the instance.

Parameters

ParameterType
thisEventIterator<V>
...valueV

Returns

void

Defined in

index.ts:80


#queue

private #queue: V[] = []

The queue of received values.

Defined in

index.ts:60


emitter

readonly emitter: EventEmitter<DefaultEventMap>

The emitter to listen to.

Defined in

index.ts:35


event

readonly event: string

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

Defined in

index.ts:40


filter

filter: EventIteratorFilter<V>

The filter used to filter out values.

Defined in

index.ts:45

Accessors

ended

Get Signature

get ended(): boolean

Whether or not the EventIterator has ended.

Returns

boolean

Defined in

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]

Defined in

index.ts:184


end()

end(): void

Ends the EventIterator.

Returns

void

Defined in

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

Defined in

index.ts:127


push()

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

Pushes a value into the queue.

Parameters

ParameterType
...valueV

Returns

void

Defined in

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

Defined in

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

Defined in

index.ts:176