Package: effect
Module: Array
Applies a function to the first element of a non-empty array, returning a new array.
When to use
Use to transform the first element of a non-empty array while preserving the rest.
Example (Modifying the head)
import { Array } from "effect"
console.log(Array.modifyHeadNonEmpty([1, 2, 3], (n) => n * 10)) // [10, 2, 3]
See
setHeadNonEmpty — replace with a fixed valuemodifyLastNonEmpty — modify the last elementSignature
declare const modifyHeadNonEmpty: { <A, B>(f: (a: A) => B): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>; <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A) => B): NonEmptyArray<A | B>; }
Since v4.0.0