Private
#privateThe number of queued items waiting to run.
The number of items currently running.
Size of the queue including running items
Adds a sync or async task to the queue. Always returns a promise.
Optional
options: JobOptionsOptional
options: boolean | AddEventListenerOptionsDispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Can be called multiple times. Useful if you for example add additional items at a later time.
Optional
options: AbortOptionsA promise that settles when the queue becomes empty.
The difference with .onEmpty
is that .onIdle
guarantees that all work
from the queue has finished. .onEmpty
merely signals that the queue is
empty, but it could mean that some promises haven't completed yet.
Optional
options: AbortOptionsA promise that settles when the queue becomes empty, and all
promises have completed; queue.size === 0 && queue.pending === 0
.
Optional
options: AbortOptionsA promise that settles when the queue size is less than the given
limit: queue.size < limit
.
If you want to avoid having the queue grow beyond a certain size you can
await queue.onSizeLessThan()
before adding a new item.
Note that this only limits the number of items waiting to start. There
could still be up to concurrency
jobs already running that this call does
not include in its calculation.
Optional
listener: null | EventHandler<QueueEvents<JobReturnType, JobOptions>[K]>Optional
options: boolean | EventListenerOptionsOptional
detail: CustomEventInit<Detail>Returns an async generator that makes it easy to iterate over the results of jobs added to the queue.
The generator will end when the queue becomes idle, that is there are no jobs running and no jobs that have yet to run.
If you need to keep the queue open indefinitely, consider using it-pushable instead.
Optional
options: AbortOptions
Extends Queue to add support for querying queued jobs by peer id