fuzzysearch
Tiny and blazing-fast fuzzy search in JavaScript

fuzzysearch downloads fuzzysearch version fuzzysearch license

fuzzysearch類似套件:
npm下載趨勢
3 年
🌟 在 fuzzysearch 的 README.md 中顯示即時使用量圖表,只需複製下面的代碼。
## Usage Trend
[![Usage Trend of fuzzysearch](https://npm-compare.com/img/npm-trend/THREE_YEARS/fuzzysearch.png)](https://npm-compare.com/fuzzysearch#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 在 fuzzysearch 的 README.md 中顯示 GitHub stars 趨勢圖表,只需複製下面的代碼。
## GitHub Stars Trend
[![GitHub Stars Trend of fuzzysearch](https://npm-compare.com/img/github-trend/fuzzysearch.png)](https://npm-compare.com/fuzzysearch)
統計詳情
套件
下載數
Stars
大小
Issues
發布時間
許可
fuzzysearch137,6992,734-511 年前MIT
fuzzysearch 的 README

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 fuzzysearch in action, head over to bevacqua.github.io/horsey, which is a demo of an autocomplete component that uses fuzzysearch to filter out results based on user input.

Install

From npm

npm install --save fuzzysearch

fuzzysearch(needle, haystack)

Returns true if needle matches haystack using 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 true only if each character in the needle can be found in the haystack and 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 horsey for an example on how that might look like.

But! RegExps...!

chart showing abysmal performance for regexp-based implementation

License

MIT