import { Arr, type Optional } from '@ephox/katamari'; export interface IndexInfo { readonly index: number; readonly candidates: A[]; } export const locate = (candidates: A[], predicate: (a: A) => boolean): Optional> => Arr.findIndex(candidates, predicate).map((index) => ({ index, candidates }));