@schie/queue - v1.0.0
    Preparing search index...

    Class Queue

    Index

    Constructors

    Properties

    onStatusChange?: (status: QueueStatus) => void

    Accessors

    • get isCancelled(): boolean

      True after cancellation has been requested.

      Returns boolean

    • get isIdle(): boolean

      True when there is no runner and no pending work.

      Returns boolean

    • get isPaused(): boolean

      True when processing is paused.

      Returns boolean

    • get isProcessing(): boolean

      True when the queue is actively processing tasks.

      Returns boolean

    • get lastTaskError(): Error | null

      Captured error from the last failed task when pause-on-error is enabled.

      Returns Error | null

    • get size(): number

      Number of tasks waiting to be processed.

      Returns number

    Methods

    • Enqueues a task to run next (ahead of other pending tasks) without preempting the current task.

      Parameters

      • task: () => Promise<void>

      Returns void

    • Enqueues a new task and starts processing if idle, resurrecting a cancelled queue.

      When a dedupeKey is provided, the queue skips enqueueing if the last pending task (or the currently running task when no tasks are pending) has the same key. This keeps only adjacent duplicates out of the queue while leaving non-adjacent repeats untouched.

      Parameters

      • task: () => Promise<void>

        Async task function to run in-order when it reaches the front of the queue.

      • OptionaldedupeKey: string

        Optional identifier used to dedupe adjacent tasks with the same key.

      Returns void

    • Cancels all pending work, clears the queue, and prevents further status flips from stale runners.

      Returns void

    • Clears the stored lastTaskError value.

      Returns void

    • Removes all pending tasks without altering status when processing or paused.

      Returns void

    • Pauses processing after the current task completes.

      Returns void

    • Resumes processing, clearing any stored error when leaving a paused state.

      Returns void