Class PeerQueue<JobReturnType, JobOptions>

Extends Queue to add support for querying queued jobs by peer id

Type Parameters

Hierarchy (view full)

Constructors

Properties

#private: any
concurrency: number
maxSize: number

Accessors

Methods

  • Dispatches 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.

    MDN Reference

    Parameters

    Returns boolean

  • Parameters

    • type: string

    Returns number

  • 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.

    Parameters

    Returns Promise<void>

    A promise that settles when the queue becomes empty, and all promises have completed; queue.size === 0 && queue.pending === 0.

  • Parameters

    Returns Promise<void>

    A 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.