cafe-utility 21.3.0 → 21.4.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 +8 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -210,6 +210,7 @@ declare function breakLine(string: string): {
|
|
|
210
210
|
line: string;
|
|
211
211
|
rest: string;
|
|
212
212
|
};
|
|
213
|
+
declare function measureTextWidth(string: string, characterWidths?: Record<string, number>): number;
|
|
213
214
|
declare function toLines(string: string, maxWidth: number, characterWidths?: Record<string, number>): string[];
|
|
214
215
|
declare function levenshteinDistance(a: string, b: string): number;
|
|
215
216
|
declare function containsWord(string: string, word: string): boolean;
|
|
@@ -814,6 +815,7 @@ export declare const Strings: {
|
|
|
814
815
|
replacePascalCaseWords: typeof replacePascalCaseWords;
|
|
815
816
|
stripHtml: typeof stripHtml;
|
|
816
817
|
breakLine: typeof breakLine;
|
|
818
|
+
measureTextWidth: typeof measureTextWidth;
|
|
817
819
|
toLines: typeof toLines;
|
|
818
820
|
levenshteinDistance: typeof levenshteinDistance;
|
|
819
821
|
};
|
package/index.js
CHANGED
|
@@ -275,7 +275,10 @@ function isObject(n, t = !0) {
|
|
|
275
275
|
(t && !isUndefined(n._readableState)) ||
|
|
276
276
|
(t &&
|
|
277
277
|
n.constructor &&
|
|
278
|
-
(n.constructor.isBuffer ||
|
|
278
|
+
(n.constructor.isBuffer ||
|
|
279
|
+
n.constructor.name == 'Uint8Array' ||
|
|
280
|
+
n.constructor.name === 'ArrayBuffer' ||
|
|
281
|
+
n.constructor.name === 'ReadableStream'))
|
|
279
282
|
? !1
|
|
280
283
|
: typeof n == 'object'
|
|
281
284
|
}
|
|
@@ -1087,6 +1090,9 @@ function breakLine(n) {
|
|
|
1087
1090
|
r = n.slice(t + 1)
|
|
1088
1091
|
return { line: e, rest: r }
|
|
1089
1092
|
}
|
|
1093
|
+
function measureTextWidth(n, t = {}) {
|
|
1094
|
+
return [...n].reduce((e, r) => e + (t[r] || 1), 0)
|
|
1095
|
+
}
|
|
1090
1096
|
function toLines(n, t, e = {}) {
|
|
1091
1097
|
const r = []
|
|
1092
1098
|
let o = '',
|
|
@@ -2591,6 +2597,7 @@ function raycastCircle(n, t, e) {
|
|
|
2591
2597
|
replacePascalCaseWords,
|
|
2592
2598
|
stripHtml,
|
|
2593
2599
|
breakLine,
|
|
2600
|
+
measureTextWidth,
|
|
2594
2601
|
toLines,
|
|
2595
2602
|
levenshteinDistance
|
|
2596
2603
|
}),
|