az-search-sorter
v1.0.4
Published
Simple fuzzy searching
Downloads
6
Readme
az-search-sorter
A function that takes a search term, things to search, and some configuration options and returns the things to search in the most logical order.
Usage:
$ npm install -S az-search-sorter
var search = require('az-search-sorter'); // available as a global in other environments as azSearchSorter
// example from a test:
const results = search('hi', ['hello', 'hi', 'Hannah Istanbul', 'secret and hidden', 'this', 'Heidi', 'hurt']);
expect(results).to.eql(['hi', 'secret and hidden', 'this', 'Hannah Istanbul', 'Heidi']);
// Note, also works with objects with the propToMatch
options
propToMatch
- allows you to specify a property of the objects in the array to matchkeepNonMatching
- allows you to specify that you wish to keep the non-matching items (at the end of the result set)
LICENSE
MIT
Code of Conduct
Credits
This was originally developed by me (Kent C. Dodds) as part of genie. I later pulled it out for use here at work at Alianza Inc. and then open sourced this piece here.