API reference › @evolu/common › Array › spliceArray
function spliceArray<T>(
array: readonly T[],
start: number,
deleteCount: number,
...items: readonly T[]
): readonly T[];
Defined in: packages/common/src/Array.ts:789
Returns a new readonly array with elements removed and/or replaced.
Wraps native toSpliced.
Removing and replacing values
import { spliceArray } from "@evolu/common";
const values: ReadonlyArray<number> = [1, 2, 3, 4];
expect(spliceArray(values, 1, 2)).toEqual([1, 4]);
expect(spliceArray([1, 2, 3], 1, 1, 10, 11)).toEqual([1, 10, 11, 3]);
expect(values).toEqual([1, 2, 3, 4]);