cafe-utility 20.0.0 → 20.1.0
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/index.d.ts +2 -0
- package/index.js +13 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -207,6 +207,7 @@ declare function breakLine(string: string): {
|
|
|
207
207
|
rest: string;
|
|
208
208
|
};
|
|
209
209
|
declare function toLines(string: string, maxWidth: number, characterWidths?: Record<string, number>): string[];
|
|
210
|
+
declare function levenshteinDistance(a: string, b: string): number;
|
|
210
211
|
declare function containsWord(string: string, word: string): boolean;
|
|
211
212
|
declare function containsWords(string: string, words: string[], mode: 'any' | 'all'): boolean;
|
|
212
213
|
declare function parseHtmlAttributes(string: string): Record<string, string>;
|
|
@@ -742,6 +743,7 @@ export declare const Strings: {
|
|
|
742
743
|
stripHtml: typeof stripHtml;
|
|
743
744
|
breakLine: typeof breakLine;
|
|
744
745
|
toLines: typeof toLines;
|
|
746
|
+
levenshteinDistance: typeof levenshteinDistance;
|
|
745
747
|
};
|
|
746
748
|
export declare const Assertions: {
|
|
747
749
|
asEqual: typeof asEqual;
|
package/index.js
CHANGED
|
@@ -1089,6 +1089,17 @@ function toLines(n, t, e = {}) {
|
|
|
1089
1089
|
}
|
|
1090
1090
|
return o && r.push(o), r
|
|
1091
1091
|
}
|
|
1092
|
+
function levenshteinDistance(n, t) {
|
|
1093
|
+
const e = []
|
|
1094
|
+
for (let r = 0; r <= n.length; r++) e[r] = [r]
|
|
1095
|
+
for (let r = 0; r <= t.length; r++) e[0][r] = r
|
|
1096
|
+
for (let r = 1; r <= n.length; r++)
|
|
1097
|
+
for (let o = 1; o <= t.length; o++) {
|
|
1098
|
+
const i = n[r - 1] === t[o - 1] ? 0 : 1
|
|
1099
|
+
e[r][o] = Math.min(e[r - 1][o] + 1, e[r][o - 1] + 1, e[r - 1][o - 1] + i)
|
|
1100
|
+
}
|
|
1101
|
+
return e[n.length][t.length]
|
|
1102
|
+
}
|
|
1092
1103
|
function containsWord(n, t) {
|
|
1093
1104
|
return new RegExp(`\\b${t}\\b`).test(n)
|
|
1094
1105
|
}
|
|
@@ -2389,7 +2400,8 @@ function raycastCircle(n, t, e) {
|
|
|
2389
2400
|
replacePascalCaseWords,
|
|
2390
2401
|
stripHtml,
|
|
2391
2402
|
breakLine,
|
|
2392
|
-
toLines
|
|
2403
|
+
toLines,
|
|
2404
|
+
levenshteinDistance
|
|
2393
2405
|
}),
|
|
2394
2406
|
(exports.Assertions = { asEqual, asTrue, asTruthy, asFalse, asFalsy, asEither }),
|
|
2395
2407
|
(exports.Cache = { get: getCached }),
|