find
ts
function Array.find<T>(
target: T[],
predicate: (
value: NoInfer<T>,
index: number,
target: readonly NoInfer<T>[],
) => boolean,
): T | undefinedReturns the first element in array that satisfies the provided predicate function, or undefined if no element is found.
Example
ts
import { Array } from "@monstermann/array";
Array.find([1, 2, 3, 4], (x) => x > 2); // 3ts
import { Array } from "@monstermann/array";
pipe(
[1, 2, 3, 4],
Array.find((x) => x > 2),
); // 3