Skip to content

insertAtOr

Array.insertAtOr(array, index, value, fallback)

Inserts value at the specified index in array, returning a new array with the inserted element, or fallback if the index is out of bounds.

Example

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

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

pipe([1, 2, 3], Array.insertAtOr(10, 99, [])); // []