leeoniya / uFuzzy

A tiny, efficient fuzzy search that doesn't suck
MIT License
2.65k stars 48 forks source link

Is there an example of stripping diacritics? #22

Closed rap2hpoutre closed 1 year ago

rap2hpoutre commented 1 year ago

In french, accent and diacritics may or may not be used by users. It should be considered. Is there an option for this?

leeoniya commented 1 year ago

there's a static utility function uFuzzy.latinize(stringsArr) that you can use to pre-process your haystack once before doing any searches, and preprocess your needle on each search.

it doesnt cover all diacritics, but does have the most common ones:

https://github.com/leeoniya/uFuzzy/blob/92fc57ea94beb8cf730599aef4c8e28d73f76833/src/uFuzzy.js#L735-L752

leeoniya commented 1 year ago

i should probably allow it to also accept a single string so there's no additional ceremony of wrapping the needle in an array and unwrapping the result.