Fuse/docs/README.md
2020-06-23 18:47:29 -07:00

87 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
noGlobalSocialShare: true
shareTitle: Fuse.js - JavaScript fuzzy-search library
---
# What is Fuse.js?
<social-share :networks="['twitter', 'reddit', 'linkedin', 'email']" />
Fuse.js is a **powerful, lightweight fuzzy-search library, with zero dependencies**.
### What is fuzzy searching?
Generally speaking, fuzzy searching (more formally known as _approximate string matching_) is the technique of finding strings that are _approximately_ equal to a given pattern (rather than _exactly_).
### Why should I use it?
- With Fuse.js, you dont need to setup a dedicated backend just to handle search.
- Simplicity and performance were the main criteria when developing this library.
::: details As easy as 1, 2, 3
```js
// 1. List of items to search in
const books = [
{
title: "Old Man's War",
author: {
firstName: 'John',
lastName: 'Scalzi'
}
},
{
title: 'The Lock Artist',
author: {
firstName: 'Steve',
lastName: 'Hamilton'
}
}
]
// 2. Set up the Fuse instance
const fuse = new Fuse(books, {
keys: ['title', 'author.firstName']
})
// 3. Now search!
fuse.search('jon')
// Output:
// [
// {
// item: {
// title: "Old Man's War",
// author: {
// firstName: 'John',
// lastName: 'Scalzi'
// }
// },
// refIndex: 0
// }
// ]
```
:::
### When should I use It?
It might not make sense for every situation, but can be ideal depending on your search requirements. For example:
- When you want client-side fuzzy searching of small to moderately large data sets.
- When you can't justify setting up a dedicated backend simply to handle search. ElasticSearch or Algolia, although both great services, may be overkill for your particular use cases.
### Can I still use it on the backend?
Of course! Fuse.js has no DOM dependencies.
### Who's using Fuse.js these days?
Plenty of people. It's hard to say an exact number, since it's free. But a good indication is the number of [dependents](https://www.npmjs.com/package/fuse.js?activeTab=dependents) on NPM, and the [dependency graph](https://github.com/krisk/Fuse/network/dependents) and [stargazers](https://github.com/krisk/Fuse/stargazers) on Github.
Read the [stories](/stories.html) to learn how various products are using Fuse.js to tackle a growing number of use cases.
---
Check out the [live demo](/demo.html) to fiddle with it and to learn how to use it.