UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

31 lines (29 loc) 655 B
import { OrElse } from "./internals/types.js"; //#region src/array/maxOrElse.d.ts /** * `maxOrElse(array, orElse)` * * Returns the maximum value from `array`, or calls `orElse` if the array is empty. * * ```ts * maxOrElse([1, 5, 3], () => 0); // 5 * maxOrElse([], () => 0); // 0 * ``` * * ```ts * pipe( * [1, 5, 3], * maxOrElse(() => 0), * ); // 5 * pipe( * [], * maxOrElse(() => 0), * ); // 0 * ``` */ declare const maxOrElse: { <T>(orElse: OrElse<number, T>): (target: readonly number[]) => number | T; <T>(target: readonly number[], orElse: OrElse<number, T>): number | T; }; //#endregion export { maxOrElse };