lastOrThrow
ts
function Array.lastOrThrow<T>(
target: readonly T[],
): Exclude<T, null | undefined>Returns the last element of array, or throws an error if the array is empty.
Example
ts
import { Array } from "@monstermann/array";
Array.lastOrThrow([1, 2, 3, 4]); // 4ts
import { Array } from "@monstermann/array";
pipe([1, 2, 3, 4], Array.lastOrThrow()); // 4