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

@acusti/matchmaking

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@acusti/matchmaking - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

src/index.test.ts

6

dist/index.d.ts

@@ -1,2 +0,6 @@

export declare const getMatchScore: (strA: string, strB: string, isSanitized?: boolean | undefined) => number;
export declare const getMatchScore: (
strA: string,
strB: string,
isSanitized?: boolean | undefined,
) => number;
declare type Payload = {

@@ -3,0 +7,0 @@ items: Array<string>;

20

dist/index.js

@@ -14,4 +14,3 @@ const FIRST_NUMBER = '0'.charCodeAt(0);

// Exact match scores 1
if (strA === strB)
return 1;
if (strA === strB) return 1;
const strALength = strA.length;

@@ -35,5 +34,7 @@ const strBLength = strB.length;

// If comparing a number to a letter, use minimum distance ('z' should be considered same distance from '3' as 'a')
if (strACharCode >= FIRST_NUMBER &&
if (
strACharCode >= FIRST_NUMBER &&
strACharCode <= LAST_NUMBER &&
strBCharCode > FIRST_LETTER) {
strBCharCode > FIRST_LETTER
) {
distance = LAST_NUMBER + 1 - strACharCode;

@@ -48,4 +49,3 @@ }

score = exactMatchBonus;
}
else {
} else {
// Non-continuous exact match gets the minimum bonus

@@ -66,4 +66,3 @@ score -= 1;

text = text.trim().toUpperCase();
if (!text || !items.length)
return items;
if (!text || !items.length) return items;
const initialValues = [[], []];

@@ -75,4 +74,3 @@ const [sortedItems] = items.reduce(([sorted, scores], item) => {

index = 0;
}
else if (itemScore > scores[scores.length - 1]) {
} else if (itemScore > scores[scores.length - 1]) {
const insertIndex = scores.findIndex((score) => score < itemScore);

@@ -90,2 +88,2 @@ if (insertIndex !== -1) {

export const getBestMatch = (payload) => sortByBestMatch(payload)[0];
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map
{
"name": "@acusti/matchmaking",
"version": "0.2.0",
"version": "0.3.0",
"type": "module",

@@ -10,3 +10,4 @@ "sideEffects": false,

"files": [
"dist"
"dist",
"src"
],

@@ -17,3 +18,3 @@ "repository": {

},
"author": "andrew patton <andrew@acusti.ca> (http://acusti.ca)",
"author": "andrew patton <andrew@acusti.ca> (https://www.acusti.ca)",
"license": "Unlicense",

@@ -25,4 +26,4 @@ "bugs": {

"devDependencies": {
"typescript": "^4.2.3"
"typescript": "^4.4.3"
}
}
# @acusti/matchmaking
![latest version](https://img.shields.io/npm/v/@acusti/matchmaking?style=for-the-badge)
![dependencies status](https://img.shields.io/david/acusti/uikit?path=packages%2Fmatchmaking&style=for-the-badge)
![bundle size](https://img.shields.io/bundlephobia/minzip/@acusti/matchmaking?style=for-the-badge)
![downloads per month](https://img.shields.io/npm/dm/@acusti/matchmaking?style=for-the-badge)
[![latest version](https://img.shields.io/npm/v/@acusti/matchmaking?style=for-the-badge)](https://www.npmjs.com/package/@acusti/matchmaking)
[![dependencies status](https://img.shields.io/david/acusti/uikit?path=packages%2Fmatchmaking&style=for-the-badge)](https://david-dm.org/acusti/uikit?path=packages%2Fmatchmaking)
[![bundle size](https://img.shields.io/bundlephobia/minzip/@acusti/matchmaking?style=for-the-badge)](https://bundlephobia.com/package/@acusti/matchmaking)
[![downloads per month](https://img.shields.io/npm/dm/@acusti/matchmaking?style=for-the-badge)](https://www.npmjs.com/package/@acusti/matchmaking)
Utilities for simple approximate string matching (i.e. fuzzy searches)

Sorry, the diff of this file is not supported yet

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