Hierarchy

  • Queue

Constructors

Methods

  • Adds a task to the queue.

    Returns

    Throws

    Error - when queue is destroyed

    Type Parameters

    • ReturnValue

    Parameters

    • taskFn: TaskFn<ReturnValue>

      task function

    • Optional data: {
          [key: string]: unknown;
      }

      data related to task, used for filtering tasks in the queue

      • [key: string]: unknown

    Returns Task<ReturnValue>

  • Adds specified queue event listener.

    Returns

    • unsubscribe function, call it to remove event listener

    Throws

    Error - when queue is destroyed or unknown event name is given

    Type Parameters

    Parameters

    • eventName: T
    • fn: EventsTypes[T]

      listener

    Returns (() => void)

      • (): void
      • Returns void

  • Adds specified queue event listener that will be called only on first occurrence of event after adding.

    Returns

    • unsubscribe function, call it to remove event listener

    Throws

    Error - when queue is destroyed or unknown event name is given

    Type Parameters

    Parameters

    • eventName: T
    • fn: EventsTypes[T]

      listener

    Returns (() => void)

      • (): void
      • Returns void

  • Destroys queue. Destroying removes waiting tasks, ongoing tasks are continued. You may manually cancel them. Destroyed instance won't allow you to do anything with it anymore.

    Returns

    • list of removed and ongoing tasks

    Returns QueueDestroyInfo

  • Returns queue size.

    Returns number

  • Returns given task position in the queue (this includes running tasks)

    Returns

    • task index or -1 if not found

    Type Parameters

    • V

    Parameters

    • task: Task<V>

      task to look for

    Returns number

  • Returns given task waiting position, 0 means the task will be first to run next time a free slot is ready

    Returns

    • task index or -1 if not found (ie: already done, already running)

    Type Parameters

    • V

    Parameters

    • task: Task<V>

      task to look for

    Returns number

  • Returns current tasks (ongoing and waiting).

    Returns

    Returns Task<any>[]

  • Adds a task to given point of the queue.

    Returns

    Throws

    Error - when queue is destroyed

    Type Parameters

    • V

    Parameters

    • taskFn: TaskFn<V>

      task function

    • index: number

      task position in the queue (starting from 0). Keep in mind that ongoing tasks are kept in this list, ie: with concurrency of 2 adding task to index 2 will mean this task will be first to run, not third.

    • Optional data: {
          [key: string]: unknown;
      }

      data related to task, used for filtering tasks in the queue

      • [key: string]: unknown

    Returns Task<V>

  • Is given task running?

    Returns

    • true if task is running, false otherwise

    Type Parameters

    • V

    Parameters

    • task: Task<V>

      task to check

    Returns boolean

  • Pauses the queue, all running tasks will continue, but new ones won't start. Unpause queue with .unpause().

    See

    unpause()

    Returns void

  • Adds a task to beginning of the queue.

    Returns

    Throws

    Error - when queue is destroyed

    Type Parameters

    • V

    Parameters

    • taskFn: TaskFn<V>

      task function

    • Optional data: {
          [key: string]: unknown;
      }

      data related to task, used for filtering tasks in the queue

      • [key: string]: unknown

    Returns Task<V>

  • Removes queue from task. This won't cancel ongoing task.

    Throws

    • when task isn't in the queue or queue is destroyed

    Type Parameters

    • V

    Parameters

    Returns void

  • Removes specified queue event listener.

    Throws

    Error - when queue is destroyed or unknown event name is given

    Type Parameters

    Parameters

    • eventName: T
    • fn: EventsTypes[T]

      listener

    Returns void

  • Changes how many tasks may run at once.

    Parameters

    • concurrency: number

      count of tasks to run at once

    Returns void

  • Unpauses the queue, tasks will be started to fill up concurrency limit.

    See

    pause()

    Returns void

Generated using TypeDoc