Détail du package

fuzzy-search

wouter2203594.2kISC3.2.1

Simple fuzzy search

fuzzy, search, javascript

readme

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.

changelog

Release Notes

3.2.1 (2020-02-20)

Fixed

  • Fix an issue where sorting is not working when the closest match of the query is at the end of the search string.

3.2.0 (2020-02-18)

Added

  • module is now registered in the package.json.

3.1.0 (2020-01-22)

Added

  • Support for numeric values.

3.0.2 (2019-10-27)

Fixed

  • Upgrade packages as some packages contained security issues.

3.0.1 (2018-01-09)

Fixed

  • Umd template for Node.

3.0.0 (2018-12-26)

Changed

  • Sorting now prefers keys close together rather than at the beginning of the string.

2.2.0 (2018-12-26)

Added

  • Keys parameter can now be omitted and configuration can be passed along in it's place.

2.1.0 (2018-06-07)

Changed

  • Allow empty haystacks

2.0.1 (2017-10-17)

Changed

Fixed

2.0.0 (2017-09-15)

Changed

  • The way it sorts
    • It now boosts scores of items that are exact matches
    • It now boosts scores of items that start with they query

1.5.0 (2017-09-15)

Changed

  • Update build tool
  • Update eslinter

Removed

  • Uncompressed compiled JavaScript

v1.4.0 (2016-11-20)

Added

  • ESLint to check code style.

Fixed

  • Errors reported by ESLint.

v1.3.8 (2016-11-20)

Fixed

  • Hide my saucelabs api key.

v1.3.7 (2016-11-20)

Fixed

  • Fix readme file.

v1.3.6 (2016-11-20)

Added

  • A changelog.

Changed

  • Show the build status of the master branch.
  • Improved README.