effect-io-ai

Package: effect
Module: Array

Array.modifyNonEmptyLast

Apply a function to the last element, creating a new NonEmptyReadonlyArray.

Example

import { Array } from "effect"

const result = Array.modifyNonEmptyLast([1, 2, 3], n => n * 2)
console.log(result) // [1, 2, 6]

Signature

declare const modifyNonEmptyLast: { <A, B>(f: (a: A) => B): (self: NonEmptyReadonlyArray<A>) => NonEmptyArray<A | B>; <A, B>(self: NonEmptyReadonlyArray<A>, f: (a: A) => B): NonEmptyArray<A | B>; }

Source

Since v2.0.0