@superhuman/command-score
Advanced tools
Comparing version 0.3.0 to 0.4.0
17
index.js
@@ -43,3 +43,3 @@ // The scores are arranged so that a continuous match of characters will | ||
// Match higher for letters closer to the beginning of the word | ||
PENALTY_DISTANCE_FROM_START = 0.9 | ||
PENALTY_DISTANCE_FROM_START = 0.9, | ||
@@ -57,6 +57,6 @@ // If the word has more characters than the user typed, it should | ||
var IS_GAP_REGEXP = /[\\\/\-_+.#"@\[\(\{&]/, | ||
COUNT_GAPS_REGEXP = /[\\\/\-_+.#"@\[\(\{&]/g, | ||
IS_SPACE_REGEXP = /\s/, | ||
COUNT_SPACE_REGEXP = /\s/g; | ||
var IS_GAP_REGEXP = /[\\\/_+.#"@\[\(\{&]/, | ||
COUNT_GAPS_REGEXP = /[\\\/_+.#"@\[\(\{&]/g, | ||
IS_SPACE_REGEXP = /[\s-]/, | ||
COUNT_SPACE_REGEXP = /[\s-]/g; | ||
@@ -132,2 +132,7 @@ function commandScoreInner(string, abbreviation, lowerString, lowerAbbreviation, stringIndex, abbreviationIndex) { | ||
function formatInput (string) { | ||
// convert all valid space characters to space so they match each other | ||
return string.toLowerCase().replace(COUNT_SPACE_REGEXP, ' ') | ||
} | ||
function commandScore(string, abbreviation) { | ||
@@ -138,5 +143,5 @@ /* NOTE: | ||
*/ | ||
return commandScoreInner(string, abbreviation, string.toLowerCase(), abbreviation.toLowerCase(), 0, 0); | ||
return commandScoreInner(string, abbreviation, formatInput(string), formatInput(abbreviation), 0, 0); | ||
} | ||
module.exports = commandScore; |
{ | ||
"name": "@superhuman/command-score", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Yet another javascript fuzzy matching library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -71,2 +71,6 @@ var expect = require('chai').expect; | ||
}); | ||
it('should match - with " " characters', function () { | ||
expect(commandScore('Auto-Advance', 'Auto Advance')).to.be.equal(0.9999) | ||
}) | ||
}); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
13027
174
1