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