Skip to content

zozo8/fuzzy-search

This branch is 8 commits behind wouterrutgers/fuzzy-search:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

57188a0 · Feb 20, 2020

History

98 Commits
Jan 22, 2020
Feb 20, 2020
Feb 20, 2020
Dec 26, 2018
Apr 23, 2016
Feb 20, 2020
Sep 15, 2017
Oct 27, 2019
Feb 20, 2020
Apr 17, 2016
May 9, 2017
Apr 24, 2016
Feb 20, 2020
Jan 9, 2019
Jan 22, 2020

Repository files navigation

Fuzzy search

Simple lightweight Fuzzy Search library written in JavaScript, with zero dependencies!

Travis npm npm Donate

Installation

Using npm

npm install fuzzy-search --save

Using <script>

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

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');

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.

About

Simple fuzzy search

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%