UNPKG

fuzzy-search-lib

Version:

A flexible fuzzy search library supporting both MongoDB and PostgreSQL

35 lines 1.11 kB
/** * Normalizes a string by converting to lowercase and removing extra whitespace. * * @param str - Input string * @returns Normalized string */ export declare function normalizeString(str: string): string; /** * Extracts field values from an object. * * @param obj - Source object * @param fields - Array of field names * @returns Concatenated field values */ export declare function extractFieldValues(obj: any, fields: string[]): string; /** * Calculates a score for a match based on multiple fields. * * @param obj - Source object * @param query - Search query * @param fields - Array of field names * @param algorithm - Algorithm function to use * @returns Match score between 0 and 1 */ export declare function calculateMatchScore(obj: any, query: string, fields: string[], algorithm: (s1: string, s2: string) => number): number; /** * Sorts results by score in descending order. * * @param results - Array of results with scores * @returns Sorted array */ export declare function sortByScore<T extends { score: number; }>(results: T[]): T[]; //# sourceMappingURL=helpers.d.ts.map