Skip to content

insertAllAt

ts
function Array.insertAllAt<T>(
    target: readonly T[],
    idx: number,
    values: Iterable<NoInfer<T>>,
): readonly T[]

Inserts all elements from values at the specified index in array, returning a new array with the inserted elements. Supports iterables for the values parameter.

Example

ts
import { Array } from "@monstermann/array";

Array.insertAllAt([1, 2, 3], 1, [10, 20]); // [1, 10, 20, 2, 3]
ts
import { Array } from "@monstermann/array";

pipe([1, 2, 3], Array.insertAllAt(1, [10, 20])); // [1, 10, 20, 2, 3]