Package: effect
Module: Array
Adds a single element to the front of an iterable, returning a NonEmptyArray.
When to use
Use when you need to guarantee a non-empty result after adding a required leading value.
Example (Prepending an element)
import { Array } from "effect"
const result = Array.prepend([2, 3, 4], 1)
console.log(result) // [1, 2, 3, 4]
See
append — add to the endprependAll — prepend multiple elementsSignature
declare const prepend: { <B>(head: B): <A>(self: Iterable<A>) => NonEmptyArray<A | B>; <A, B>(self: Iterable<A>, head: B): NonEmptyArray<A | B>; }
Since v2.0.0