aboutsummaryrefslogtreecommitdiff
path: root/src/lib/search.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/search.ts')
-rw-r--r--src/lib/search.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/search.ts b/src/lib/search.ts
new file mode 100644
index 0000000..7b9530e
--- /dev/null
+++ b/src/lib/search.ts
@@ -0,0 +1,11 @@
+export function match(search: string, target: string): boolean {
+ return search.split(/\s+/).every(s => format(target).includes(format(s)))
+}
+
+export function format(str: string): string {
+ return unaccent(str.toLowerCase())
+}
+
+function unaccent(str: string): string {
+ return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "")
+}