Type Parameters

  • T

Implements

Constructors

Properties

averageProcessTime: number = 0
highestProcessTime: number = 0
itemsAdded: number = 0
itemsAddedPerSecond: number = 0
itemsProcessed: number = 0
itemsProcessedPerSecond: number = 0
itemsRemoved: number = 0
itemsRemovedPerSecond: number = 0
lowestProcessTime: number = 0
maxQueueSize: number

The maximum number of items that can be stored in the queue

nextDelay: number

The amount of time in ms to wait before retrieving the next item in the queue

Callback to run when an item is added to the queue

onClear?: () => void | Promise<void>

Callback to run when the queue is cleared

onEmpty?: () => void | Promise<void>

Callback to run when the queue is empty

onProcessEnd?: QueueCallbackFunction<T>

Callback to run when an item is processed

onProcessStart?: QueueCallbackFunction<T>

Callback to run when an item is about to be processed

Callback to run when an item is removed from the queue

processFunction?: QueueCallbackFunction<T>

The function to run on each item in the queue, before continuing to the next item

processInterval: undefined | Timeout
resumeOnEmptyTimeout: undefined | Timeout
skipProcessOnFull: boolean

Should we skip processing the first item in the queue when it's full and an item is added?

stopOnEmpty: boolean = false

Should we stop processing once the queue is empty, or wait for more items to be added?

waitOnEmpty: number

The amount of time to wait before resuming once the queue is empty

default: {
    maxQueueSize: number;
    nextDelay: number;
    skipProcessOnFull: boolean;
    waitOnEmpty: number;
} = ...

Methods

  • Adds an item to the queue

    Parameters

    • item: T

    Returns void

  • Clears the queue

    Returns Promise<void>

  • Returns undefined | T

  • Retrieves the first item in the queue without removing it

    Returns undefined | T

    The first item in the queue

  • Starts processing the queue, never initialized internally so requires explicit call to start, static queue if never called

    Returns Promise<undefined | T>

  • Removes an item from the queue

    Parameters

    • item: T

    Returns undefined | T