@optique/core 1.0.0-dev.1495 → 1.0.0-dev.1499
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/suggestion.cjs +3 -0
- package/dist/suggestion.js +3 -0
- package/package.json +1 -1
package/dist/suggestion.cjs
CHANGED
|
@@ -81,8 +81,11 @@ function findSimilar(input, candidates, options = {}) {
|
|
|
81
81
|
if (input.length === 0) return [];
|
|
82
82
|
const normalizedInput = caseSensitive ? input : input.toLowerCase();
|
|
83
83
|
const matches = [];
|
|
84
|
+
const seen = /* @__PURE__ */ new Set();
|
|
84
85
|
for (const candidate of candidates) {
|
|
85
86
|
const normalizedCandidate = caseSensitive ? candidate : candidate.toLowerCase();
|
|
87
|
+
if (seen.has(candidate)) continue;
|
|
88
|
+
seen.add(candidate);
|
|
86
89
|
const distance = levenshteinDistance(normalizedInput, normalizedCandidate);
|
|
87
90
|
if (distance === 0) return [candidate];
|
|
88
91
|
const distanceRatio = distance / input.length;
|
package/dist/suggestion.js
CHANGED
|
@@ -81,8 +81,11 @@ function findSimilar(input, candidates, options = {}) {
|
|
|
81
81
|
if (input.length === 0) return [];
|
|
82
82
|
const normalizedInput = caseSensitive ? input : input.toLowerCase();
|
|
83
83
|
const matches = [];
|
|
84
|
+
const seen = /* @__PURE__ */ new Set();
|
|
84
85
|
for (const candidate of candidates) {
|
|
85
86
|
const normalizedCandidate = caseSensitive ? candidate : candidate.toLowerCase();
|
|
87
|
+
if (seen.has(candidate)) continue;
|
|
88
|
+
seen.add(candidate);
|
|
86
89
|
const distance = levenshteinDistance(normalizedInput, normalizedCandidate);
|
|
87
90
|
if (distance === 0) return [candidate];
|
|
88
91
|
const distanceRatio = distance / input.length;
|