Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@superhuman/command-score

Package Overview
Dependencies
Maintainers
10
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superhuman/command-score - npm Package Compare versions

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)
})
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc