MCPcopy Create free account
hub / github.com/webpack/webpack-cli / distance

Function distance

packages/webpack-cli/src/webpack-cli.ts:430–448  ·  view source on GitHub ↗
(first: string, second: string)

Source from the content-addressed store, hash-verified

428// suggestions. Exported only so it can be unit-tested directly; the CLI uses it
429// through the private `WebpackCLI.#distance`.
430export function distance(first: string, second: string): number {
431 let a = first;
432 let b = second;
433
434 if (a.length < b.length) {
435 const tmp = b;
436
437 b = a;
438 a = tmp;
439 }
440
441 if (b.length === 0) {
442 return a.length;
443 }
444
445 levenshteinPeq ??= new Uint32Array(0x10000);
446
447 return a.length <= 32 ? myers32(a, b, levenshteinPeq) : myersX(a, b, levenshteinPeq);
448}
449
450class ConfigurationLoadingError extends Error {
451 name = "ConfigurationLoadingError";

Callers 2

#distanceMethod · 0.85

Calls 2

myers32Function · 0.85
myersXFunction · 0.85

Tested by

no test coverage detected