Package Exports
- fuzzy-search
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fuzzy-search) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Fuzzy search
Simple fuzzy search
Uses String.indexOf
instead of RegExp
to make this library 3 times faster than libraries that use RegExp
!
Installation
Using npm
npm install fuzzy-search --save
Using
<script>
<script src="fuzzy-search.min.js"></script>
Quick start guide
// This can be excluded when loaded via <script>
import FuzzySearch from 'fuzzy-search'; // Or: var FuzzySearch = require('fuzzy-search');
var people = [{
name: {
firstName: 'Jesse',
lastName: 'Bowen',
},
state: 'Seattle',
}];
var fuzzy = new FuzzySearch(people, ['name.firstName', 'state'], {
caseSensitive: true,
});
var result = fuzzy.search('ess');
Documentation
var fuzzy = new FuzzySearch(<haystack>, [keys], [options]);
var result = fuzzy.search(<needle>);
<hackstack>
(Array) Array of objects containing the search list
[keys]
(Array) List of properties that will be searched. This also supports nested properties.
[options]
(Object) Object with options that will configure the search
<needle>
(String) The string to search on
Options
caseSensitive (type: Boolean
)
Indicates whether comparisons should be case sensitive.
sort (type: Boolean
)
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