blob: 026cb94d3e4457f62561df5414989abb5a039ad0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
export function match(search: string, ...targets: Array<string | undefined>): boolean {
const formattedTargets = targets
.filter(t => t !== undefined)
.map(format)
return search.split(/\s+/).every(subSearch =>
formattedTargets.some(target => target.includes(format(subSearch)))
)
}
export function format(str: string): string {
return unaccent(str.toLowerCase())
}
function unaccent(str: string): string {
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "")
}
|