tryFindIndexBack

Finds an Option of index of last element in an array that satisfies a predicate function. Returns None if no element is found.

Type

type tryFindIndexBack = <E>(predicate: ((e: E) => boolean)) => (a: Array<E>) => Option<number>

Example

import {tryFindIndexBack} from 'fnxt/array';

function isEven(num: number): boolean {
  return num % 2 === 0;
}

const array = [1, 2, 3, 4, 5];
const findEven = tryFindIndexBack(isEven);
findEven(array) // -> Some(3)

See Also