Skip to content

prepend

ts
function Array.prepend<T>(
    target: readonly T[],
    value: NoInfer<T>,
): T[]

Adds value to the beginning of array.

Example

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

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

pipe([2, 3, 4], Array.prepend(1)); // [1, 2, 3, 4]