UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

23 lines (21 loc) 474 B
import { NonNil } from "../internals/types.js"; //#region src/array/lastOrThrow.d.ts /** * `lastOrThrow(array)` * * Returns the last element of `array`, or throws an error if the array is empty. * * ```ts * lastOrThrow([1, 2, 3, 4]); // 4 * ``` * * ```ts * pipe([1, 2, 3, 4], lastOrThrow()); // 4 * ``` */ declare const lastOrThrow: { (): <T>(target: readonly T[]) => NonNil<T>; <T>(target: readonly T[]): NonNil<T>; }; //#endregion export { lastOrThrow };