2023-11-17 20:51:13 +03:00
|
|
|
/**
|
|
|
|
* Module: API for Library entities and Users.
|
|
|
|
*/
|
|
|
|
|
2023-12-13 14:32:57 +03:00
|
|
|
import { TextMatcher } from '@/utils/utils';
|
|
|
|
|
2023-11-17 20:51:13 +03:00
|
|
|
import { ILibraryItem } from './library';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a given target {@link ILibraryItem} matches the specified query.
|
2023-12-28 14:04:44 +03:00
|
|
|
*
|
2023-11-17 20:51:13 +03:00
|
|
|
* @param target - item to be matched
|
|
|
|
* @param query - text to be found in target attributes
|
|
|
|
*/
|
|
|
|
export function matchLibraryItem(target: ILibraryItem, query: string): boolean {
|
|
|
|
const matcher = new TextMatcher(query);
|
|
|
|
return matcher.test(target.alias) || matcher.test(target.title);
|
2023-12-28 14:04:44 +03:00
|
|
|
}
|