indexOfOr
ts
function Array.indexOfOr<T, U>(
target: readonly T[],
value: NoInfer<T>,
or: U,
): number | UReturns the index of the first occurrence of value in target. If value is not found, returns or.
Example
ts
import { Array } from "@monstermann/array";
Array.indexOfOr([1, 2, 3, 2], 2, -1); // 1
Array.indexOfOr([1, 2, 3], 4, -1); // -1ts
import { Array } from "@monstermann/array";
pipe([1, 2, 3, 2], Array.indexOfOr(2, -1)); // 1
pipe([1, 2, 3], Array.indexOfOr(4, -1)); // -1