Skip to content

minOrElse

Array.minOrElse(target, orElse)

Returns the minimum value from target array, or calls orElse if the array is empty.

Example

ts
import { Array } from "@monstermann/array";

Array.minOrElse([5, 2, 8, 1], () => 0); // 1
Array.minOrElse([], () => 0); // 0
ts
import { Array } from "@monstermann/array";

pipe(
    [5, 2, 8, 1],
    Array.minOrElse(() => 0),
); // 1

pipe(
    [],
    Array.minOrElse(() => 0),
); // 0