Skip to main content

Class: EventIterator<V>

event-iterator/src.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:88

Properties

#ended

Private #ended: boolean = false

Whether or not the EventIterator has ended.

Defined in

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


#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:55


#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:75


#limit

Private #limit: number

The limit before ending the EventIterator.

Defined in

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


#passed

Private #passed: number = 0

The amount of events that have passed the filter.

Defined in

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


#push

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

Type declaration

▸ (this, ...value): void

The push handler with context bound to the instance.

Parameters
NameType
thisEventIterator<V>
...valueV
Returns

void

Defined in

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


#queue

Private #queue: V[] = []

The queue of received values.

Defined in

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


emitter

Readonly emitter: EventEmitter

The emitter to listen to.

Defined in

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


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:40


filter

filter: EventIteratorFilter<V>

The filter used to filter out values.

Defined in

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

Accessors

ended

get ended(): boolean

Whether or not the EventIterator has ended.

Returns

boolean

Defined in

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

Methods

[asyncIterator]

[asyncIterator](): AsyncIterableIterator<V>

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

Returns

AsyncIterableIterator<V>

Implementation of

AsyncIterableIterator.__@asyncIterator@79589

Defined in

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


end

end(): void

Ends the EventIterator.

Returns

void

Defined in

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


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:131


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:195


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:172


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:180