UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

31 lines (29 loc) 840 B
import { ArrayPredicate } from "./internals/types.js"; //#region src/array/findIndexOr.d.ts /** * `findIndexOr(target, predicate, or)` * * Returns the index of the first element in `target` that satisfies the provided `predicate` function. If no element satisfies the predicate, returns `or`. * * ```ts * findIndexOr([1, 2, 3, 4], (x) => x > 2, -1); // 2 * findIndexOr([1, 2, 3, 4], (x) => x > 5, -1); // -1 * ``` * * ```ts * pipe( * [1, 2, 3, 4], * findIndexOr((x) => x > 2, -1), * ); // 2 * pipe( * [1, 2, 3, 4], * findIndexOr((x) => x > 5, -1), * ); // -1 * ``` */ declare const findIndexOr: { <T, U>(predicate: ArrayPredicate<T>, or: U): (target: readonly T[]) => number | U; <T, U>(target: readonly T[], predicate: ArrayPredicate<T>, or: U): number | U; }; //#endregion export { findIndexOr };