@ac-essentials/misc-util
    Preparing search index...

    Interface IQueue<T>

    Interface representing a FIFO (First In First Out) queue.

    A queue is a collection that follows the First In First Out (FIFO) principle, where the first item added to the queue is the first one to be removed.

    interface IQueue<T = unknown> {
        capacity: number;
        "[asyncIterator]"(): AsyncIterator<T, any, any>;
        "[iterator]"(): Iterator<Promisable<T>, any, any>;
        clear(): Promisable<void>;
        concat(...items: T[]): MaybeAsyncIterableIterator<T>;
        count(): Promisable<number>;
        dequeue(): Promisable<undefined | T>;
        enqueue(...items: T[]): Promisable<void>;
        front(): Promisable<undefined | T>;
        remove(
            condition: Predicate<[T]>,
        ): Promisable<MaybeAsyncIterableIterator<T>>;
        removeFirst(condition: Predicate<[T]>): Promisable<boolean>;
        replace(
            condition: Predicate<[T]>,
            newItemFactory: Callable<[T], T>,
        ): Promisable<MaybeAsyncIterableIterator<T>>;
        replaceFirst(condition: Predicate<[T]>, newItem: T): Promisable<boolean>;
        waitEnqueue(
            items: Iterable<T>,
            signal?: null | AbortSignal,
        ): PromiseLike<void>;
    }

    Type Parameters

    • T = unknown

      The type of elements in the queue.

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    capacity: number

    The maximum number of elements the collection can hold. If the collection is unbounded, this will be Infinity.

    Methods

    • Returns AsyncIterator<T, any, any>

    • Returns Iterator<Promisable<T>, any, any>

    • Adds one or more items to the rear of the queue.

      The items are added in the order they are provided. The last item in the argument list will be the last one to be dequeued.

      Parameters

      • ...items: T[]

        The items to add to the queue.

      Returns Promisable<void>

      If the operation would exceed the queue's capacity.

    • Same as enqueue, but waits for capacity if the operation would exceed it.

      Parameters

      • items: Iterable<T>
      • Optionalsignal: null | AbortSignal

        Optional abort signal to cancel the operation.

      Returns PromiseLike<void>

      IQueue.enqueue