UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

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