Skip to content

findOr

Array.findOr(array, predicate, fallback)

Returns the first element in array that satisfies the provided predicate function, or fallback if no element is found.

Example

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

Array.findOr([1, 2, 3, 4], (x) => x > 10, 0); // 0
ts
import { Array } from "@monstermann/array";

pipe(
    [1, 2, 3, 4],
    Array.findOr((x) => x > 10, 0),
); // 0