closest-property
Version:
When given an object and a string, will return the value corresponding to the key that is the closest (according to the levenshtein distance, where case is ignored) to the given string.
21 lines (20 loc) • 550 B
TypeScript
/**
* Calculates the number of edits to get from input1 to input2 where an edit is
* one of:
*
* 1. Add a character;
* 2. Delete a character; or,
* 3. Replace a character.
*
* @param input1
* @param input2
*/
export declare const editDistance: (input1?: string, input2?: string) => number;
/**
* When given an object and a target string, returns the [first] value with the
* key that is the least distance from the target string.
*
* @param obj
* @param target
*/
export default function closest(obj: any, target: string): undefined;