UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

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