this is 115 lines of TS, which is pretty lightweight, but some other impt table stakes might be missing that you should be aware of.<p>see all the JS alternatives with their sizes and feature sets and perf: <a href="https://github.com/leeoniya/uFuzzy">https://github.com/leeoniya/uFuzzy</a> (scroll to bottom)<p>i went down this path a few yrs ago and ended up picking ufuzzy: <a href="https://swyxkit.netlify.app/ufuzzy-search" rel="nofollow">https://swyxkit.netlify.app/ufuzzy-search</a>
I never realized search like this was this easy to build in a way.<p>It’s a very clever RegEx engine, essentially. Though it’s unclear to me right now how will this library handles fuzzy search (e.g. Califnia instead of California) but it’s really cool to reason about its implementation
With FlexSearch
or lunr or similar, building an index is so fast for “thousands of items” that it’s fine to do it when the user opens a search interface and forget it once they’re done.