Represents a queue

Hierarchy

  • EventEmitter
    • Queue

Constructors

Accessors

  • get size(): number
  • Gets the size of the queue

    Returns number

Methods

  • Clears the queue

    Returns void

  • Dequeues and returns the next job in the queue

    Returns undefined | TaskHandler<any, any>

    The next job, or undefined if the queue is empty

  • Drops the oldest job in the queue with the lowest priority if not priority is provided, and drops the oldest job with a lower priority than the provided priority otherwise

    Parameters

    • Optionalpriority: number

      The priority of the job to drop

    Returns undefined | TaskHandler<any, any>

    The dropped job, or undefined if the queue is empty

    The queue is ordered by priority and age, this means that first jobs have a higher priority, and if several jobs have the same priority, the oldest one its earlier in the queue

  • Enqueues a job with optional priority

    Parameters

    Returns boolean

  • Peeks the next job in the queue

    Returns undefined | TaskHandler<any, any>

    The next job, or undefined if the queue is empty

  • Emitted when a job is enqueued

    Parameters

    • event: "enqueue"
    • listener: () => void

    Returns this

  • Emitted when a job is dequeued

    Parameters

    • event: "dequeue"
    • listener: () => void

    Returns this

  • Emitted when a job is removed

    Parameters

    • event: "removed"
    • listener: () => void

    Returns this

  • Emitted when the queue is cleared

    Parameters

    • event: "cleared"
    • listener: () => void

    Returns this

  • Emitted when the queue is blocked

    Parameters

    • event: "blocked"
    • listener: () => void

    Returns this

  • Emitted when the queue is unblocked

    Parameters

    • event: "unblocked"
    • listener: () => void

    Returns this

  • Emitted when the queue is empty

    Parameters

    • event: "empty"
    • listener: () => void

    Returns this

  • Emitted when the bucket is refilled

    Parameters

    • event: "refill"
    • listener: () => void

    Returns this

  • Emitted when the queue is empty and a job is enqueued

    Parameters

    • event: "seed"
    • listener: () => void

    Returns this

  • Removes a job from the queue

    Parameters

    • uuid: string

      The uuid of the job to remove

    Returns undefined | TaskHandler<any, any>