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
| Parameter | Type | Description |
|---|---|---|
emitter | EventEmitter<DefaultEventMap> | The event emitter to listen to. |
event | string | The event we're listening for to receives values from. |
options | EventIteratorOptions<V> | Any extra options. |
Returns
Source
Properties
#ended
private#ended:boolean=false
Whether or not the EventIterator has ended.
Source
#idle?
privateoptional#idle:number
The amount of idle time in ms before moving on.
Source
#idleTimer
private#idleTimer:undefined|null|Timeout=null
The timer to track when this will idle out.
Source
#limit
private#limit:number
The limit before ending the EventIterator.
Source
#passed
private#passed:number=0
The amount of events that have passed the filter.
Source
#push()
private#push: (this:EventIterator<V>, ...value:V) =>void
The push handler with context bound to the instance.
Parameters
| Parameter | Type |
|---|---|
this | EventIterator<V> |
...value | V |
Returns
void
Source
#queue
private#queue:V[] =[]
The queue of received values.
Source
emitter
readonlyemitter:EventEmitter<DefaultEventMap>
The emitter to listen to.
Source
event
readonlyevent:string
The event the event iterator is listening for to receive values from.
Source
filter
filter:
EventIteratorFilter<V>
The filter used to filter out values.
Source
Accessors
ended
getended():boolean
Whether or not the EventIterator has ended.
Returns
boolean
Source
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
end()
end():
void
Ends the EventIterator.
Returns
void
Source
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
push()
protectedpush(...value:V):void
Pushes a value into the queue.
Parameters
| Parameter | Type |
|---|---|
...value | V |
Returns
void
Source
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
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