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

    Interface IList<T>

    Interface representing an ordered data collection.

    The list does not allow undefined as a valid element.

    The list may or may not be optimized for random access, depending on the implementation.

    Contrary to Javascript Array, the list cannot be sparse (i.e., it cannot have "holes" or missing elements). All indices between 0 and count() - 1 are guaranteed to be valid.

    The list may have a fixed capacity, in which case it cannot grow beyond that capacity. If the list is unbounded, its capacity is Infinity.

    interface IList<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>;
        get(index: number): 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>;
        set(index: number, item: T): Promisable<void>;
        slice(
            start?: number,
            end?: number,
        ): Promisable<MaybeAsyncIterableIterator<T>>;
        splice(
            start: number,
            deleteCount?: number,
            ...items: T[],
        ): Promisable<MaybeAsyncIterableIterator<T>>;
        waitSet(
            index: number,
            item: T,
            signal?: null | AbortSignal,
        ): PromiseLike<void>;
        waitSplice(
            start: number,
            deleteCount?: number,
            items?: Iterable<T, any, any>,
            signal?: null | AbortSignal,
        ): PromiseLike<MaybeAsyncIterableIterator<T>>;
    }

    Type Parameters

    • T = unknown

      The type of elements in the list.

    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>

    • Returns the item at the specified index.

      If the index is negative, it counts from the end of the list. If the index is out of bounds, undefined is returned.

      Parameters

      • index: number

        The index of the item to retrieve.

      Returns Promisable<undefined | T>

      The item at the specified index, or undefined if the index is out of bounds.

    • Sets the item at the specified index.

      If the index is negative, it counts from the end of the list. If the index is equal to the length of the list, the item is appended to the end. If the index is out of bounds, a RangeError is thrown.

      Parameters

      • index: number

        The index at which to set the item.

      • item: T

        The item to set.

      Returns Promisable<void>

      If the index is out of bounds.

      If the operation would exceed the list's capacity.

    • Slice the list to a new list from start to end.

      This method does not mutate the original list.

      The range is specified by the start and end parameters, which are inclusive and exclusive, respectively. If start is omitted, it defaults to 0. If end is omitted, it defaults to the length of the list.

      If either start or end is negative, they refer to positions from the end of the list. For example, -1 refers to the last element, -2 refers to the second last element, and so on.

      If start is greater than or equal to end, the result is an empty iterator.

      If the start index is out of bounds, a RangeError is thrown. If end is out of bounds, it is clamped to the valid range.

      Parameters

      • Optionalstart: number

        Optional start index of the range (inclusive).

      • Optionalend: number

        Optional end index of the range (exclusive).

      Returns Promisable<MaybeAsyncIterableIterator<T>>

      An iterator for the elements in the specified range.

      If the start index is out of bounds.

    • Change the content of the list by removing or replacing existing elements and/or adding new elements in place.

      If the start index is negative, it counts from the end of the list. If the start index is equal to the length of the list, no elements are removed and the items are appended to the end of the list. If the start index is out of bounds, a RangeError is thrown.

      If deleteCount is omitted, it defaults to Infinity, meaning all elements from the start index to the end of the list will be removed. If deleteCount is greater than the number of elements from start to the end of the list, it will remove all elements from start to the end of the list. If deleteCount is 0 or negative, no elements will be removed.

      If items are provided, they will be inserted starting at the start index.

      Parameters

      • start: number

        The index at which to start changing the list.

      • OptionaldeleteCount: number

        The number of elements to remove from the list. Defaults to Infinity

      • ...items: T[]

        The elements to add to the list, beginning at the start index.

      Returns Promisable<MaybeAsyncIterableIterator<T>>

      An iterable of the removed items.

      If the start index is out of bounds.

      If the operation would exceed the list's capacity.

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

      Parameters

      • index: number
      • item: T
      • Optionalsignal: null | AbortSignal

        Optional abort signal to cancel the operation.

      Returns PromiseLike<void>

      IList.set

    • The same as splice, but waits for capacity if the operation would exceed it.

      Parameters

      • start: number
      • OptionaldeleteCount: number
      • Optionalitems: Iterable<T, any, any>
      • Optionalsignal: null | AbortSignal

        Optional abort signal to cancel the operation.

      Returns PromiseLike<MaybeAsyncIterableIterator<T>>

      IList.splice