@monstermann/fn
Version:
A utility library for TypeScript.
22 lines • 621 B
TypeScript
//#region src/array/indexOfOrThrow.d.ts
/**
* `indexOfOrThrow(target, value)`
*
* Returns the index of the first occurrence of `value` in `target`. If `value` is not found, throws an error.
*
* ```ts
* indexOfOrThrow([1, 2, 3, 2], 2); // 1
* indexOfOrThrow([1, 2, 3], 4); // throws FnError
* ```
*
* ```ts
* pipe([1, 2, 3, 2], indexOfOrThrow(2)); // 1
* pipe([1, 2, 3], indexOfOrThrow(4)); // throws FnError
* ```
*/
declare const indexOfOrThrow: {
<T>(value: NoInfer<T>): (target: readonly T[]) => number;
<T>(target: readonly T[], value: NoInfer<T>): number;
};
//#endregion
export { indexOfOrThrow };