# fuzzysearch

> Tiny and blazing-fast fuzzy search in JavaScript

Latest version **1.0.3** (published 2015-03-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install fuzzysearch
pnpm add fuzzysearch
yarn add fuzzysearch
bun add fuzzysearch
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2015-03-06 |
| First published | 2015-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/fuzzysearch) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2741 |
| Author | Nicolas Bevacqua |
| Maintainers | bevacqua |

## Links

- npm: https://www.npmjs.com/package/fuzzysearch
- Repository: https://github.com/bevacqua/fuzzysearch
- Issues: https://github.com/bevacqua/fuzzysearch/issues
- npm.io page: https://npm.io/package/fuzzysearch

## Recent versions

- 1.0.3 (latest) — 2015-03-06
- 1.0.2 — 2015-03-05
- 1.0.1 — 2015-03-03
- 1.0.0 — 2015-03-03

## 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][3], which is a demo of an autocomplete component that uses `fuzzysearch` to filter out results based on user input.

# Install

From `npm`

```shell
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][2]_, 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.

```js
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][3] for an example on how that might look like.

# But! _`RegExp`s...!_

![chart showing abysmal performance for regexp-based implementation][1]

# License

MIT

[1]: https://cloud.githubusercontent.com/assets/934293/6495796/106a61a6-c2ac-11e4-945d-3d1bb066a76e.png
[2]: http://en.wikipedia.org/wiki/Levenshtein_distance
[3]: http://bevacqua.github.io/horsey

---
_Source: https://npm.io/package/fuzzysearch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
