mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-29 16:18:55 +00:00
15 lines
464 B
TypeScript
15 lines
464 B
TypeScript
export function filterDatabaseOptions(
|
|
options: string[],
|
|
query: string,
|
|
displayName: (option: string) => string = (option) => option,
|
|
): string[] {
|
|
const normalizedQuery = query.trim().toLowerCase();
|
|
if (!normalizedQuery) return options;
|
|
|
|
return options.filter((option) => {
|
|
const raw = option.toLowerCase();
|
|
const label = displayName(option).toLowerCase();
|
|
return raw.includes(normalizedQuery) || label.includes(normalizedQuery);
|
|
});
|
|
}
|