fuzzysearch

Tiny and blazing-fast fuzzy search in JavaScript

fuzzysearch

Tiny and blazing-fast fuzzy search in JavaScript

Fuzzy searching allows for flexibly matching a string with partial input, useful for filtering data very quickly based on lightweight user input.

Demo

To see fuzzysearchin action, head over to bevacqua.github.io/horsey, which is a demo of an autocomplete component that uses fuzzysearchto filter out results based on user input.

Install

From npm

npm install --save fuzzysearch
fuzzysearch(needle, haystack)

Returns trueif needlematches haystackusing a fuzzy-searching algorithm. Note that this program doesn't implement _levenshtein distance_, but rather a simplified version where there's no approximation. The method will return trueonly if each character in the needlecan be found in the haystackand occurs after the preceding character.

fuzzysearch('twl', 'cartwheel') // <- true
fuzzysearch('cart', 'cartwheel') // <- true
fuzzysearch('cw', 'cartwheel') // <- true
fuzzysearch('ee', 'cartwheel') // <- true
fuzzysearch('art', 'cartwheel') // <- true
fuzzysearch('eeel', 'cartwheel') // <- false
fuzzysearch('dog', 'cartwheel') // <- false

An exciting application for this kind of algorithm is to filter options from an autocomplete menu, check out horseyfor an example on how that might look like.

But! RegExps...!

License

MIT

HomePage

https://github.com/bevacqua/fuzzysearch

Repository

https://github.com/bevacqua/fuzzysearch


上一篇:lie-ts
下一篇:int64-buffer

相关推荐

  • list.fuzzysearch.js

    list.fuzzysearch.js是什么 什么是list.fuzzysearch.js,A fuzzy search plugin for List.js list.fuzzysearch...

    2 年前

官方社区

扫码加入 JavaScript 社区