From a04348205543d9aaeb5d7d75f7603d972b9f5e9e Mon Sep 17 00:00:00 2001 From: ka-weihe Date: Thu, 23 Jul 2020 01:06:34 +0200 Subject: [PATCH 1/3] faster levenshtein --- package-lock.json | 8 +++++++- package.json | 2 +- src/scripts/utils/sanitizeConfig.ts | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 263769291..026d7a01b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7374,6 +7374,11 @@ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, + "fastest-levenshtein": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.9.tgz", + "integrity": "sha512-8DIQrqkmGTMfjcwiebj28Y1l6eCoLCU+TppdZa5zp5ZyNO12oUhtEEeCZjojZZarD8+peRg3CxL4Zm5BrKr9Fw==" + }, "fastq": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.6.0.tgz", @@ -11726,7 +11731,8 @@ "leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", - "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==" + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true }, "levenary": { "version": "1.1.1", diff --git a/package.json b/package.json index 165b08c54..8cb2f5368 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "es6-promise": "^4.2.8", "escodegen": "^1.12.0", "estree-walker": "~0.9.0", + "fastest-levenshtein": "^1.0.9", "findup": "^0.1.5", "function.name-polyfill": "^1.0.6", "github-slugger": "^1.2.1", @@ -60,7 +61,6 @@ "jss-plugin-isolate": "^10.0.0", "jss-plugin-nested": "^10.0.0", "kleur": "^3.0.3", - "leven": "^3.1.0", "listify": "^1.0.0", "loader-utils": "^2.0.0", "lodash": "^4.17.15", diff --git a/src/scripts/utils/sanitizeConfig.ts b/src/scripts/utils/sanitizeConfig.ts index 5c6e8b8c9..fcafadfe0 100644 --- a/src/scripts/utils/sanitizeConfig.ts +++ b/src/scripts/utils/sanitizeConfig.ts @@ -10,7 +10,7 @@ import isFinite from 'lodash/isFinite'; import map from 'lodash/map'; import listify from 'listify'; import kleur from 'kleur'; -import leven from 'leven'; +import levenshtein from 'fastest-levenshtein'; import typeDetect from 'type-detect'; import loggerMaker from 'glogg'; import { stringify } from 'q-i'; @@ -57,7 +57,7 @@ export default function sanitizeConfig>( // Try to guess const possibleOptions = Object.keys(schema); const suggestedOption = possibleOptions.reduce((suggestion: string, option: string) => { - const steps = leven(option, key); + const steps = levenshtein.distance(option, key); if (steps < 2) { return option; } From 0303daaa514f9ff953708b690b7e958227ed1f56 Mon Sep 17 00:00:00 2001 From: fzzle Date: Fri, 24 Jul 2020 00:33:06 +0200 Subject: [PATCH 2/3] Fix request --- src/scripts/utils/sanitizeConfig.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/utils/sanitizeConfig.ts b/src/scripts/utils/sanitizeConfig.ts index fcafadfe0..2ee690de6 100644 --- a/src/scripts/utils/sanitizeConfig.ts +++ b/src/scripts/utils/sanitizeConfig.ts @@ -10,7 +10,7 @@ import isFinite from 'lodash/isFinite'; import map from 'lodash/map'; import listify from 'listify'; import kleur from 'kleur'; -import levenshtein from 'fastest-levenshtein'; +import { distance } from 'fastest-levenshtein'; import typeDetect from 'type-detect'; import loggerMaker from 'glogg'; import { stringify } from 'q-i'; @@ -57,7 +57,7 @@ export default function sanitizeConfig>( // Try to guess const possibleOptions = Object.keys(schema); const suggestedOption = possibleOptions.reduce((suggestion: string, option: string) => { - const steps = levenshtein.distance(option, key); + const steps = distance(option, key); if (steps < 2) { return option; } From 681e2b6eb9e3ed7821f5093876a0815b19363771 Mon Sep 17 00:00:00 2001 From: ka-weihe Date: Mon, 3 Aug 2020 14:17:20 +0200 Subject: [PATCH 3/3] Trigger ci