cafe-utility 21.3.1 → 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.
Files changed (3) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +4 -0
  3. 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
@@ -1090,6 +1090,9 @@ function breakLine(n) {
1090
1090
  r = n.slice(t + 1)
1091
1091
  return { line: e, rest: r }
1092
1092
  }
1093
+ function measureTextWidth(n, t = {}) {
1094
+ return [...n].reduce((e, r) => e + (t[r] || 1), 0)
1095
+ }
1093
1096
  function toLines(n, t, e = {}) {
1094
1097
  const r = []
1095
1098
  let o = '',
@@ -2594,6 +2597,7 @@ function raycastCircle(n, t, e) {
2594
2597
  replacePascalCaseWords,
2595
2598
  stripHtml,
2596
2599
  breakLine,
2600
+ measureTextWidth,
2597
2601
  toLines,
2598
2602
  levenshteinDistance
2599
2603
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "21.3.1",
3
+ "version": "21.4.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {