@monstermann/fn
Version:
A utility library for TypeScript.
25 lines (23 loc) • 525 B
JavaScript
import { dfdlT } from "@monstermann/dfdl";
//#region src/array/findIndex.ts
/**
* `findIndex(array, predicate)`
*
* Returns the index of the first element in `array` that satisfies the provided `predicate` function, or -1 if no element is found.
*
* ```ts
* findIndex([1, 2, 3, 4], (x) => x > 2); // 2
* ```
*
* ```ts
* pipe(
* [1, 2, 3, 4],
* findIndex((x) => x > 2),
* ); // 2
* ```
*/
const findIndex = dfdlT((target, predicate) => {
return target.findIndex(predicate);
}, 2);
//#endregion
export { findIndex };