Skip to main content

Class: EventIterator<V>

Defined in: index.ts:31

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, event: string, options: EventIteratorOptions<V>): EventIterator<V>

Defined in: index.ts:87

Parameters

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

Returns

EventIterator<V>

Properties

#ended

private #ended: boolean = false

Defined in: index.ts:50

Whether or not the EventIterator has ended.


#idle?

private readonly optional #idle: number

Defined in: index.ts:55

The amount of idle time in ms before moving on.


#idleTimer

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

Defined in: index.ts:75

The timer to track when this will idle out.


#limit

private readonly #limit: number

Defined in: index.ts:70

The limit before ending the EventIterator.


#passed

private #passed: number = 0

Defined in: index.ts:65

The amount of events that have passed the filter.


#push()

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

Defined in: index.ts:80

The push handler with context bound to the instance.

Parameters

ParameterType
thisEventIterator<V>
...valueV

Returns

void


#queue

private #queue: V[] = []

Defined in: index.ts:60

The queue of received values.


emitter

readonly emitter: EventEmitter

Defined in: index.ts:35

The emitter to listen to.


event

readonly event: string

Defined in: index.ts:40

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


filter

filter: EventIteratorFilter<V>

Defined in: index.ts:45

The filter used to filter out values.

Accessors

ended

Get Signature

get ended(): boolean

Defined in: index.ts:107

Whether or not the EventIterator has ended.

Returns

boolean

Methods

[asyncIterator]()

[asyncIterator](): AsyncIterableIterator<V>

Defined in: index.ts:184

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

Returns

AsyncIterableIterator<V>

Implementation of

AsyncIterableIterator.[asyncIterator]


end()

end(): void

Defined in: index.ts:114

Ends the EventIterator.

Returns

void


next()

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

Defined in: index.ts:127

The next value that's received from the EventEmitter.

Returns

Promise<IteratorResult<V, any>>

Implementation of

AsyncIterableIterator.next


push()

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

Defined in: index.ts:191

Pushes a value into the queue.

Parameters

ParameterType
...valueV

Returns

void


return()

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

Defined in: index.ts:168

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

Returns

Promise<IteratorResult<V, any>>

Implementation of

AsyncIterableIterator.return


throw()

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

Defined in: index.ts:176

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

Returns

Promise<IteratorResult<V, any>>

Implementation of

AsyncIterableIterator.throw