@sanity/form-builder
Version:
Sanity form builder
19 lines • 1.1 kB
TypeScript
/**
* Find the index of the nearest element with the same value. Starts at given index and looks incrementally in either direction for the searchElement
* It's *NOT* inclusive: If the element matches the element at the startIdx, startIdx will be returned
* It prefers matches in the first half. If there's a tie it will pick the first element that comes before
* @param array
* @param startIdx
* @param searchElement
*/
export declare function nearestIndexOf<T>(array: T[], startIdx: number, searchElement: T): number;
/**
* Find the index of the nearest element matching the predicate. Starts at given index and looks incrementally in either direction
* It's *NOT* inclusive: If the predicate matches the element at the startIdx, startIdx will be returned
* It prefers matches in the first half. If there's a tie it will pick the first element that comes before
* @param array
* @param startIdx
* @param predicate
*/
export declare function nearestIndex<T>(array: T[], startIdx: number, predicate: (element: T, index: number) => boolean): number;
//# sourceMappingURL=nearestIndex.d.ts.map