fast-fuzzy
Advanced tools
Comparing version 1.2.0 to 1.2.1
13
fuzzy.js
@@ -15,4 +15,5 @@ const nonWordRegex = /[`~!@#$%^&*()\-=_+{}[\]\|\\;':",./<>?]+/g; | ||
function normalize(string, options) { | ||
string = string.normalize(); | ||
if (options.ignoreCase) { | ||
string = string.toLowerCase(); | ||
string = string.toLocaleLowerCase(); | ||
} | ||
@@ -73,2 +74,10 @@ if (options.ignoreSymbols) { | ||
//wrapper for exporting sellers while allowing options to be passed in | ||
function fuzzy(term, candidate, options) { | ||
options = Object.assign({}, defaultOptions, options); | ||
term = normalize(term, options); | ||
candidate = normalize(candidate, options); | ||
return sellers(term, candidate); | ||
} | ||
//simple one-off search. Useful if you don't expect to use the same candidate list again | ||
@@ -98,5 +107,5 @@ function search(term, candidates, options) { | ||
module.exports = { | ||
fuzzy: sellers, | ||
fuzzy, | ||
search, | ||
Searcher, | ||
}; |
{ | ||
"name": "fast-fuzzy", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Fast and tiny fuzzy-search utility", | ||
@@ -5,0 +5,0 @@ "main": "fuzzy.js", |
@@ -27,1 +27,3 @@ # fast-fuzzy [![Build Status](https://travis-ci.org/EthanRutherford/fast-fuzzy.svg?branch=master)](https://travis-ci.org/EthanRutherford/fast-fuzzy) | ||
* objects are returned in the form `{item, key, score}` | ||
`fuzzy` accepts a subset of these options (ignoreCase, ignoreSymbols, normalizeWhitespace) with the same defaults. |
@@ -42,2 +42,9 @@ /* global describe, it */ | ||
}); | ||
it("should accept options", () => { | ||
assert.notEqual( | ||
fuzzy("hello", "HELLO"), | ||
fuzzy("hello", "HELLO", {ignoreCase: false}) | ||
); | ||
}); | ||
}); | ||
@@ -44,0 +51,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12326
252
29