find-closest
Version:
Like Array.prototype.find, but for finding the closest match.
13 lines (12 loc) • 403 B
TypeScript
import type { Finder } from './types';
/**
* Returns the index of the item in an array that is closest to the value
* specified by the `target` argument.
*/
export declare const findClosestIndex: Finder<'index'>;
/**
* Returns the item in an array that is closest to the value specified by the
* `target` argument.
*/
export declare const findClosest: Finder<'value'>;
export default findClosest;