UNPKG

@playcanvas/pcui

Version:

User interface component library for the web

32 lines (31 loc) 1.07 kB
type SearchArgs = { /** * Tolerance for how many characters of the search string must be contained in the item name. Default is 0.5. */ containsCharsTolerance?: number; /** * Tolerance for how many edits are allowed between the search string and the item name. Default is 0.5. */ editsDistanceTolerance?: number; /** * Limit the number of results. If not set, all results will be returned. */ limitResults?: number; }; /** * Perform search through items. * * @param items - Array of objects to search through. * @param searchKey - The property name to search within each item. * @param search - String to search for. * @param args - Search arguments. * @returns Array of found items. * @example * const items = [ * { text: 'Item 1', id: 1 }, * { text: 'Item 2', id: 2 } * ]; * const results = searchItems(items, 'text', 'item'); */ export declare const searchItems: <K extends string, T extends Record<K, string>>(items: T[], searchKey: K, search?: string, args?: SearchArgs) => T[]; export {};