fuzzy-search
Simple fuzzy search
Last updated 2 months ago by GitHub Actions .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ npm install fuzzy-search 
SYNC missed versions from official npm registry.

Fuzzy search

Simple lightweight fuzzy search library written in JavaScript, with zero runtime dependencies!

Checks npm npm Donate

Installation

Using npm

npm install fuzzy-search

Using pnpm

pnpm add fuzzy-search

Using <script>

<script src="FuzzySearch.js"></script>

The browser bundle is available at dist/FuzzySearch.js in the published package and exposes FuzzySearch globally.

Quick start guide

// This can be excluded when loaded via <script>
import FuzzySearch from 'fuzzy-search'; // Or: var FuzzySearch = require('fuzzy-search');

const people = [{
  name: {
    firstName: 'Jesse',
    lastName: 'Bowen',
  },
  state: 'Seattle',
}];

const searcher = new FuzzySearch(people, ['name.firstName', 'state'], {
  caseSensitive: true,
});
const result = searcher.search('ess');

Development

Use Node.js 24 and pnpm. Run pnpm install, pnpm test, pnpm lint, pnpm build, and pnpm test:package.

Documentation

const searcher = new FuzzySearch(<haystack>, [keys], [options]);
const result = searcher.search(<needle>);

haystack (type: Array)

Array of objects containing the search list.


[keys] (type: Array, default: [])

List of properties that will be searched. This also supports nested properties.


[options] (type: Object)

Object with options that will configure the search. Scroll/Swipe down to see more information on what options are available.


<needle> (type: String, default: '')

The string to Fuzzy Search on.

Options

caseSensitive (type: Boolean, default: false)

Indicates whether comparisons should be case sensitive.

sort (type: Boolean, default: false)

When true it will sort the results by best match (when searching for abc in the search set ['a__b__c', 'abc'] it would return abc as the first result).

When false it will return the results in the original order.

Current Tags

  • 3.3.0                                ...           latest (2 months ago)

31 Versions

  • 3.3.0                                ...           2 months ago
  • 3.2.1                                ...           7 years ago
  • 3.2.0                                ...           7 years ago
  • 3.1.0                                ...           7 years ago
  • 3.0.2                                ...           7 years ago
  • 2.2.1                                ...           8 years ago
  • 3.0.1                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 2.2.0                                ...           8 years ago
  • 2.1.0                                ...           8 years ago
  • 2.0.1                                ...           9 years ago
  • 2.0.0                                ...           9 years ago
  • 1.5.0                                ...           9 years ago
  • 1.4.0                                ...           10 years ago
  • 1.3.8                                ...           10 years ago
  • 1.3.7                                ...           10 years ago
  • 1.3.6                                ...           10 years ago
  • 1.3.5                                ...           11 years ago
  • 1.3.4                                ...           11 years ago
  • 1.3.3                                ...           11 years ago
  • 1.3.1                                ...           11 years ago
  • 1.3.0                                ...           11 years ago
  • 1.2.5                                ...           11 years ago
  • 1.2.4                                ...           11 years ago
  • 1.2.3                                ...           11 years ago
  • 1.2.2                                ...           11 years ago
  • 1.2.1                                ...           11 years ago
  • 1.2.0                                ...           11 years ago
  • 1.1.1                                ...           11 years ago
  • 1.1.0                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Total 39
Today 0
This Week 5
This Month 22
Last Day 1
Last Week 6
Last Month 10
Dependencies (0)
None
Dev Dependencies (4)

© 2010 - cnpmjs.org x YWFE | Home | YWFE