@kayahr/signal
    Preparing search index...

    Interface ArrayMutator<T>

    Mutates an array signal without exposing direct write access to the current snapshot.

    interface ArrayMutator<T> {
        clear(): void;
        pop(): T | undefined;
        push(...items: T[]): number;
        replace(items: readonly T[]): void;
        set(index: number, value: T): T;
        shift(): T | undefined;
        splice(start: number, deleteCount?: number, ...items: T[]): T[];
        unshift(...items: T[]): number;
        update(index: number, update: (value: T) => T): T;
    }

    Type Parameters

    • T
    Index

    Methods

    • Removes all items from the array.

      Returns void

    • Removes the last item from the array.

      Returns T | undefined

      The removed item, if there was one.

    • Appends items to the end of the array.

      Parameters

      • ...items: T[]

        The items to append.

      Returns number

      The new array length.

    • Replaces the whole array content.

      Parameters

      • items: readonly T[]

        The new array content.

      Returns void

    • Replaces the item at the given index.

      Parameters

      • index: number

        The index of the item to replace.

      • value: T

        The new item value.

      Returns T

      The written value.

      RangeError - When index is not a valid existing array index.

    • Removes the first item from the array.

      Returns T | undefined

      The removed item, if there was one.

    • Removes and optionally inserts items at the given position.

      Parameters

      • start: number

        The index at which to start changing the array.

      • OptionaldeleteCount: number

        The number of items to remove.

      • ...items: T[]

        The items to insert at start.

      Returns T[]

      The removed items.

    • Prepends items to the beginning of the array.

      Parameters

      • ...items: T[]

        The items to prepend.

      Returns number

      The new array length.

    • Replaces the item at the given index with a value derived from the current item.

      Parameters

      • index: number

        The index of the item to replace.

      • update: (value: T) => T

        Derives the new item value from the current one.

      Returns T

      The written value.

      RangeError - When index is not a valid existing array index.