From f91732269b6af43615d149a0231ef0faf38ea535 Mon Sep 17 00:00:00 2001 From: Piotr Bulawa Date: Tue, 26 Sep 2023 15:15:59 +0200 Subject: [PATCH] Replace string-similarity with fastest-levenshtein --- lib/connection/connection_config.js | 9 +++------ package.json | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/connection/connection_config.js b/lib/connection/connection_config.js index 526f95a74..d8b3d459a 100644 --- a/lib/connection/connection_config.js +++ b/lib/connection/connection_config.js @@ -10,7 +10,7 @@ const ErrorCodes = Errors.codes; const NativeTypes = require('./result/data_types').NativeTypes; const GlobalConfig = require('../global_config'); const authenticationTypes = require('../authentication/authentication').authenticationTypes; -const stringSimilarity = require("string-similarity"); +const levenshtein = require('fastest-levenshtein'); const RowMode = require('./../constants/row_mode'); const WAIT_FOR_BROWSER_ACTION_TIMEOUT = 120000; const DEFAULT_PARAMS = @@ -484,12 +484,9 @@ function ConnectionConfig(options, validateCredentials, qaMode, clientInfo) { if (!DEFAULT_PARAMS.includes(key)) { - var matches = stringSimilarity.findBestMatch(key, DEFAULT_PARAMS); + const result = levenshtein.closest(key, DEFAULT_PARAMS); console.error(`"${key}" is an unknown connection parameter`); - if (matches.bestMatchIndex > 0) - { - console.error(`Did you mean "${matches.bestMatch.target}"`); - } + console.error(`Did you mean "${result}"`); } } } diff --git a/package.json b/package.json index ca97385cc..cd9762626 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "expand-tilde": "^2.0.2", "extend": "^3.0.2", "fast-xml-parser": "^4.2.5", + "fastest-levenshtein": "^1.0.16", "generic-pool": "^3.8.2", "glob": "^7.1.6", "https-proxy-agent": "^5.0.1", @@ -31,7 +32,6 @@ "open": "^7.3.1", "python-struct": "^1.1.3", "simple-lru-cache": "^0.0.2", - "string-similarity": "^4.0.4", "tmp": "^0.2.1", "uuid": "^8.3.2", "winston": "^3.1.0"