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

    Interface ICollection<T>

    Interface representing a collection of elements.

    interface ICollection<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>;
        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>;
    }

    Type Parameters

    • T = unknown

      The type of elements in the collection.

    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>

    • Replaces the first occurence of the item matching the given predicate in the collection with a new item.

      Parameters

      • condition: Predicate<[T]>

        A predicate function to identify the item to replace.

      • newItem: T

        The new item to insert.

      Returns Promisable<boolean>

      true if the item was found and replaced, false otherwise.