Reactive array interface without modifying methods.

See also ReactiveArray.

interface ReadonlyReactiveArray<T> {
    length: number;
    at(index: number): undefined | T;
    concat(...values: T[]): ReactiveArray<T>;
    concat(...values: (ReadonlyReactiveArray<T> | T | T[])[]): ReactiveArray<T>;
    entries(): IterableIterator<[index: number, value: T]>;
    every(predicate: (value: T, index: number) => boolean): boolean;
    filter<U>(
        predicate: (value: T, index: number) => value is U,
    ): ReactiveArray<U>;
    filter(predicate: (value: T, index: number) => boolean): ReactiveArray<T>;
    find<U>(predicate: (value: T, index: number) => value is U): undefined | U;
    find(predicate: (value: T, index: number) => boolean): undefined | T;
    findIndex(predicate: (value: T, index: number) => boolean): number;
    findLast<U>(
        predicate: (value: T, index: number) => value is U,
    ): undefined | U;
    findLast(predicate: (value: T, index: number) => boolean): undefined | T;
    findLastIndex(predicate: (value: T, index: number) => boolean): number;
    flatMap<U>(
        callback: (value: T, index: number) => U | readonly U[],
    ): ReactiveArray<U>;
    forEach(callback: (value: T, index: number) => void): void;
    get(index: number): undefined | T;
    getItems(): T[];
    includes(value: T, fromIndex?: number): boolean;
    indexOf(value: T, fromIndex?: number): number;
    keys(): IterableIterator<number>;
    lastIndexOf(value: T): number;
    map<U>(callback: (value: T, index: number) => U): ReactiveArray<U>;
    reduce(
        callback: (
            previousValue: T,
            currentValue: T,
            currentIndex: number,
        ) => T,
    ): T;
    reduce(
        callback: (
            previousValue: T,
            currentValue: T,
            currentIndex: number,
        ) => T,
        initialValue: T,
    ): T;
    reduce<U>(
        callback: (
            previousValue: U,
            currentValue: T,
            currentIndex: number,
        ) => U,
        initialValue: U,
    ): U;
    reduceRight(
        callback: (
            previousValue: T,
            currentValue: T,
            currentIndex: number,
        ) => T,
    ): T;
    reduceRight(
        callback: (
            previousValue: T,
            currentValue: T,
            currentIndex: number,
        ) => T,
        initialValue: T,
    ): T;
    reduceRight<U>(
        callback: (
            previousValue: U,
            currentValue: T,
            currentIndex: number,
        ) => U,
        initialValue: U,
    ): U;
    set(index: number, value: T): void;
    slice(start?: number): ReactiveArray<T>;
    slice(start: number, end?: number): ReactiveArray<T>;
    some(predicate: (value: T, index: number) => boolean): boolean;
    values(): IterableIterator<T>;
}

Type Parameters

  • T

Hierarchy (View Summary)

Methods

  • Returns the item at the given index, or undefined if the index is out of bounds. You can use negative indices to address items starting from the end of the array.

    See also Array.at.

    Parameters

    • index: number

    Returns undefined | T

  • Returns an iterator over the [index, value] entries in this array.

    Returns IterableIterator<[index: number, value: T]>

  • Returns true if the predicate is satisfied for every item in this array, false otherwise.

    See also Array.every.

    Parameters

    • predicate: (value: T, index: number) => boolean

    Returns boolean

  • Returns the first item that satisfies the given predicate, or undefined if there is no such item.

    See also Array.find.

    Type Parameters

    • U

    Parameters

    • predicate: (value: T, index: number) => value is U

    Returns undefined | U

  • Returns the first item that satisfies the given predicate, or undefined if there is no such item.

    See also Array.find.

    Parameters

    • predicate: (value: T, index: number) => boolean

    Returns undefined | T

  • Returns the index of the first item that satisfies the given predicate, -1 if no such item was found.

    See also Array.findIndex.

    Parameters

    • predicate: (value: T, index: number) => boolean

    Returns number

  • Returns the last item that satisfies the given predicate, or undefined if there is no such item.

    See also Array.findLast.

    Type Parameters

    • U

    Parameters

    • predicate: (value: T, index: number) => value is U

    Returns undefined | U

  • Returns the last item that satisfies the given predicate, or undefined if there is no such item.

    See also Array.findLast.

    Parameters

    • predicate: (value: T, index: number) => boolean

    Returns undefined | T

  • Returns the index of the first item that satisfies the given predicate, -1 if no such item was found.

    See also Array.findLastIndex.

    Parameters

    • predicate: (value: T, index: number) => boolean

    Returns number

  • Returns a new array where every item has been replaced with the result of calling the given callback function. If the callback function returns an array, the items in that array are included individually.

    See also Array.flatMap.

    Type Parameters

    • U

    Parameters

    • callback: (value: T, index: number) => U | readonly U[]

    Returns ReactiveArray<U>

  • Executes the given callback for every item in the array.

    See also Array.forEach.

    Parameters

    • callback: (value: T, index: number) => void

    Returns void

  • Returns the item at the given index, or undefined if the index is out of bounds.

    Parameters

    • index: number

    Returns undefined | T

  • Returns a new, non-reactive array with this array's current content.

    Returns T[]

  • Searches for the given value and returns true if it was found, false otherwise.

    See also Array.includes.

    Parameters

    • value: T
    • OptionalfromIndex: number

    Returns boolean

  • Searches for the given value and returns its index, or -1 if it was not found.

    See also Array.indexOf.

    Parameters

    • value: T
    • OptionalfromIndex: number

    Returns number

  • Returns an iterator over the indices in this array.

    Returns IterableIterator<number>

  • Searches backwards for the given value and returns its index, or -1 if it was not found.

    See also Array.lastIndexOf.

    Parameters

    • value: T

    Returns number

  • Calls the given callback function for all items in this array. The return value of the previous callback invocation is passed in the next call. The final result of the callback will be returned from this function.

    See also Array.reduce.

    Parameters

    • callback: (previousValue: T, currentValue: T, currentIndex: number) => T

    Returns T

  • Calls the given callback function for all items in this array. The return value of the previous callback invocation is passed in the next call. The final result of the callback will be returned from this function.

    See also Array.reduce.

    Parameters

    • callback: (previousValue: T, currentValue: T, currentIndex: number) => T
    • initialValue: T

    Returns T

  • Calls the given callback function for all items in this array. The return value of the previous callback invocation is passed in the next call. The final result of the callback will be returned from this function.

    See also Array.reduce.

    Type Parameters

    • U

    Parameters

    • callback: (previousValue: U, currentValue: T, currentIndex: number) => U
    • initialValue: U

    Returns U

  • Calls the given callback function for all items in this array, starting from the back. The return value of the previous callback invocation is passed in the next call. The final result of the callback will be returned from this function.

    See also Array.reduceRight.

    Parameters

    • callback: (previousValue: T, currentValue: T, currentIndex: number) => T

    Returns T

  • Calls the given callback function for all items in this array, starting from the back. The return value of the previous callback invocation is passed in the next call. The final result of the callback will be returned from this function.

    See also Array.reduceRight.

    Parameters

    • callback: (previousValue: T, currentValue: T, currentIndex: number) => T
    • initialValue: T

    Returns T

  • Calls the given callback function for all items in this array, starting from the back. The return value of the previous callback invocation is passed in the next call. The final result of the callback will be returned from this function.

    See also Array.reduceRight.

    Type Parameters

    • U

    Parameters

    • callback: (previousValue: U, currentValue: T, currentIndex: number) => U
    • initialValue: U

    Returns U

  • Sets the item at the given index to value.

    Parameters

    • index: number
    • value: T

    Returns void

  • Returns true if at least one item satisfies the given predicate, false otherwise.

    See also Array.some.

    Parameters

    • predicate: (value: T, index: number) => boolean

    Returns boolean

  • Returns an iterator over the items in this array.

    Returns IterableIterator<T>

Properties

length: number

Returns the current number of items in this array.