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
Defined in
Properties
#ended
private
#ended:boolean
=false
Whether or not the EventIterator has ended.
Defined in
#idle?
private
readonly
optional
#idle:number
The amount of idle time in ms before moving on.
Defined in
#idleTimer
private
readonly
#idleTimer:undefined
|null
|Timeout
=null
The timer to track when this will idle out.
Defined in
#limit
private
readonly
#limit:number
The limit before ending the EventIterator.
Defined in
#passed
private
#passed:number
=0
The amount of events that have passed the filter.
Defined in
#push()
private
readonly
#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
Defined in
#queue
private
#queue:V
[] =[]
The queue of received values.
Defined in
emitter
readonly
emitter:EventEmitter
<DefaultEventMap
>
The emitter to listen to.
Defined in
event
readonly
event:string
The event the event iterator is listening for to receive values from.
Defined in
filter
filter:
EventIteratorFilter
<V
>
The filter used to filter out values.
Defined in
Accessors
ended
Get Signature
get ended():
boolean
Whether or not the EventIterator has ended.
Returns
boolean
Defined in
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
end()
end():
void
Ends the EventIterator.
Returns
void
Defined in
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
push()
protected
push(...value
:V
):void
Pushes a value into the queue.
Parameters
Parameter | Type |
---|---|
...value | V |
Returns
void
Defined in
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
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