AsyncQueue
Class: AsyncQueue<T>
Defined in: packages/core/src/core/asyncqueue.ts:5
A push-based async iterable: producers push, one consumer iterates. end() (or the consumer leaving the loop)
finishes it; items pushed after the end are dropped.
Type Parameters
T
T
Implements
AsyncIterable<T>
Constructors
Constructor
new AsyncQueue<
T>(options?):AsyncQueue<T>
Defined in: packages/core/src/core/asyncqueue.ts:36
Create a new AsyncQueue instance
Parameters
options?
optional settings
size?
(item) => number
measures an item in bytes, to track pendingBytes
Returns
AsyncQueue<T>
Accessors
ended
Get Signature
get ended():
boolean
Defined in: packages/core/src/core/asyncqueue.ts:44
Get whether the queue is finished
Returns
boolean
whether the queue is finished
pending
Get Signature
get pending():
number
Defined in: packages/core/src/core/asyncqueue.ts:77
Get the number of items pushed and not yet consumed
Returns
number
the number of items pushed and not yet consumed
pendingBytes
Get Signature
get pendingBytes():
number
Defined in: packages/core/src/core/asyncqueue.ts:69
Get the size of the items pushed and not yet consumed (0 when no size is given)
Returns
number
the size of the items pushed and not yet consumed (0 when no size is given)
Methods
[asyncIterator]()
[asyncIterator]():
AsyncIterator<T>
Defined in: packages/core/src/core/asyncqueue.ts:114
Return the async iterator for this instance
Returns
AsyncIterator<T>
the iterator
Implementation of
AsyncIterable.[asyncIterator]
end()
end(
discard?):void
Defined in: packages/core/src/core/asyncqueue.ts:85
No more items.
Parameters
discard?
boolean = false
also drop the items not consumed yet
Returns
void
next()
next():
Promise<IteratorResult<T,any>>
Defined in: packages/core/src/core/asyncqueue.ts:100
Return the next item, without ending the queue (unlike breaking out of a for await)
Returns
Promise<IteratorResult<T, any>>
the next item, without ending the queue (unlike breaking out of a for await)
push()
push(
item,size?):void
Defined in: packages/core/src/core/asyncqueue.ts:53
Push operation
Parameters
item
T
the next item
size?
number
its size in bytes (defaults to the size function's result)
Returns
void