@visulima/string 3.0.0-alpha.1 → 3.0.0-alpha.11
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/CHANGELOG.md +155 -0
- package/LICENSE.md +429 -1
- package/README.md +72 -20
- package/dist/align-text.d.ts +7 -10
- package/dist/align-text.js +7 -5
- package/dist/case/camel-case.d.ts +3 -5
- package/dist/case/camel-case.js +7 -7
- package/dist/case/capital-case.d.ts +3 -5
- package/dist/case/capital-case.js +3 -3
- package/dist/case/constant-case.d.ts +3 -5
- package/dist/case/dot-case.d.ts +3 -5
- package/dist/case/flat-case.d.ts +3 -5
- package/dist/case/flip-case.d.ts +4 -7
- package/dist/case/flip-case.js +8 -2
- package/dist/case/identify-case.d.ts +3 -5
- package/dist/case/identify-case.js +2 -1
- package/dist/case/index.d.ts +23 -25
- package/dist/case/index.js +1 -1
- package/dist/case/kebab-case.d.ts +6 -9
- package/dist/case/kebab-case.js +3 -3
- package/dist/case/lower-first.d.ts +3 -5
- package/dist/case/no-case.d.ts +3 -5
- package/dist/case/pascal-case.d.ts +3 -5
- package/dist/case/pascal-case.js +3 -3
- package/dist/case/pascal-snake-case.d.ts +3 -5
- package/dist/case/path-case.d.ts +3 -5
- package/dist/case/sentence-case.d.ts +3 -5
- package/dist/case/sentence-case.js +7 -7
- package/dist/case/snake-case.d.ts +3 -5
- package/dist/case/split-by-case.d.ts +11 -14
- package/dist/case/split-by-case.js +171 -52
- package/dist/case/title-case.d.ts +3 -5
- package/dist/case/title-case.js +3 -5
- package/dist/case/train-case.d.ts +3 -5
- package/dist/case/train-case.js +1 -1
- package/dist/case/upper-first.d.ts +3 -5
- package/dist/closest-string.d.ts +3 -5
- package/dist/closest-string.js +5 -8
- package/dist/compare-similarity.d.ts +3 -5
- package/dist/compare-similarity.js +2 -2
- package/dist/get-string-truncated-width.d.ts +18 -20
- package/dist/get-string-truncated-width.js +2 -33
- package/dist/get-string-width.d.ts +2 -5
- package/dist/index.d.ts +49 -45
- package/dist/index.js +12 -4
- package/dist/native-string-types.d.ts +145 -128
- package/dist/outdent.d.ts +9 -11
- package/dist/outdent.js +7 -15
- package/dist/packem_shared/closestN-DUsjgiXb.js +25 -0
- package/dist/packem_shared/{constants-CTzC6Gjg.js → constants-BsZS5f0z.js} +1 -1
- package/dist/packem_shared/countOccurrences-CS9XprQN.js +22 -0
- package/dist/packem_shared/direction-C9gfWWTK.js +16 -0
- package/dist/packem_shared/eastAsianWidthType-SD3YniiT.js +20 -0
- package/dist/packem_shared/excerpt-COsVNttN.js +1502 -0
- package/dist/packem_shared/indent-D3DSCa6s.js +33 -0
- package/dist/packem_shared/isFullwidthCodePoint-IFXZxNjq.js +10 -0
- package/dist/packem_shared/{joinSegments-CuU8RGpP.js → joinSegments-CvxSgKz0.js} +1 -1
- package/dist/packem_shared/lookup-BE8lEqy4.js +104 -0
- package/dist/packem_shared/lru-cache.d-BsP6kbVJ.d.ts +13 -0
- package/dist/packem_shared/{normalize-german-eszett-DEB8-ZPT.js → normalize-german-eszett-4p3yKEzn.js} +2 -1
- package/dist/packem_shared/redent-DSb1IJWn.js +8 -0
- package/dist/packem_shared/{replaceString-vYvRBMfC.js → replaceString-Ce8X2ZQ-.js} +19 -17
- package/dist/packem_shared/stripIndent-D_TRjxZ_.js +20 -0
- package/dist/packem_shared/{transliterate-CYnKKT8f.js → transliterate-CKt9VK7D.js} +10 -12
- package/dist/packem_shared/{types-Daae0hGf.d.ts → types.d-BVNv675q.d.ts} +18 -21
- package/dist/packem_shared/{types-CfPsw9ix.d.ts → types.d-DfgbcNKh.d.ts} +19 -21
- package/dist/slice.d.ts +5 -8
- package/dist/slice.js +9 -7
- package/dist/slugify.d.ts +1 -3
- package/dist/slugify.js +1 -1
- package/dist/test/utils.d.ts +20 -22
- package/dist/test/utils.js +2 -2
- package/dist/test/vitest.d.ts +3 -6
- package/dist/truncate.d.ts +7 -10
- package/dist/truncate.js +49 -26
- package/dist/utilities.d.ts +2 -4
- package/dist/utilities.js +6 -8
- package/dist/word-similarity-sort.d.ts +3 -5
- package/dist/word-wrap.d.ts +9 -11
- package/dist/word-wrap.js +37 -35
- package/package.json +2 -2
- package/dist/packem_shared/closestN-BREy4E7C.js +0 -19
- package/dist/packem_shared/lru-cache-B_t27XwI.d.ts +0 -14
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { L as LocaleOptions, i as SplitByCase } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { L as LocaleOptions, i as SplitByCase } from "../packem_shared/types.d-DfgbcNKh.js";
|
|
2
|
+
import "../packem_shared/types.d-BVNv675q.js";
|
|
3
|
+
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
5
4
|
interface SplitOptions extends LocaleOptions {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
handleAnsi?: boolean;
|
|
6
|
+
handleEmoji?: boolean;
|
|
7
|
+
knownAcronyms?: ReadonlyArray<string>;
|
|
8
|
+
normalize?: boolean;
|
|
9
|
+
separators?: ReadonlyArray<string> | RegExp;
|
|
10
|
+
stripAnsi?: boolean;
|
|
11
|
+
stripEmoji?: boolean;
|
|
13
12
|
}
|
|
14
13
|
declare const splitByCase: <T extends string = string>(input: T, options?: SplitOptions) => SplitByCase<T>;
|
|
15
|
-
|
|
16
|
-
export { splitByCase };
|
|
17
|
-
export type { SplitOptions };
|
|
14
|
+
export { SplitOptions, splitByCase };
|
|
@@ -20,16 +20,17 @@ const __cjs_getBuiltinModule = (module) => {
|
|
|
20
20
|
const {
|
|
21
21
|
stripVTControlCharacters
|
|
22
22
|
} = __cjs_getBuiltinModule("node:util");
|
|
23
|
-
import {
|
|
23
|
+
import { i as RE_EMOJI, s as stripEmoji, R as RE_FAST_ANSI, l as RE_CYRILLIC, m as RE_LATIN, n as RE_GREEK, o as RE_GREEK_LATIN_SPLIT, p as RE_UZBEK_LATIN_MODIFIER, q as RE_KATAKANA, r as RE_KANJI, t as RE_HIRAGANA, u as RE_HANGUL, v as RE_HEBREW, w as RE_ARABIC, x as RE_SEPARATORS, y as RE_DEVANAGARI, z as RE_BENGALI, A as RE_GUJARATI, B as RE_GURMUKHI, C as RE_KANNADA, D as RE_TAMIL, E as RE_TELUGU, F as RE_MALAYALAM, G as RE_SINHALA, H as RE_THAI, I as RE_LAO, J as RE_TIBETAN, K as RE_MYANMAR, L as RE_ETHIOPIC, M as RE_KHMER, N as RE_ORIYA } from '../packem_shared/constants-BsZS5f0z.js';
|
|
24
24
|
import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
|
|
25
25
|
|
|
26
26
|
const regexCache = new LRUCache(1e3);
|
|
27
|
+
const RE_ESCAPE_SPECIAL = /[.*+?^${}()|[\]\\]/g;
|
|
27
28
|
const getSeparatorsRegex = (separators) => {
|
|
28
29
|
const key = separators.join("");
|
|
29
30
|
if (regexCache.has(key)) {
|
|
30
31
|
return regexCache.get(key);
|
|
31
32
|
}
|
|
32
|
-
const pattern = separators.map((s) => s.replaceAll(
|
|
33
|
+
const pattern = separators.map((s) => s.replaceAll(RE_ESCAPE_SPECIAL, String.raw`\$&`)).join("|");
|
|
33
34
|
const regex = new RegExp(pattern, "g");
|
|
34
35
|
regexCache.set(key, regex);
|
|
35
36
|
return regex;
|
|
@@ -53,6 +54,7 @@ const splitByEmoji = (text) => {
|
|
|
53
54
|
return segments.filter(Boolean);
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
const RE_SLOVENIAN_SPECIAL = /[ČŠŽĐ]/i;
|
|
56
58
|
const isUpperCode = new Uint8Array(128);
|
|
57
59
|
const isLowerCode = new Uint8Array(128);
|
|
58
60
|
const isDigitCode = new Uint8Array(128);
|
|
@@ -69,8 +71,9 @@ const handleScriptTransitions = (s, scriptDetectors, caseSensitive, locale, cust
|
|
|
69
71
|
return [];
|
|
70
72
|
}
|
|
71
73
|
let hasDetectedScript = false;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
const detectorValues = Object.values(scriptDetectors);
|
|
75
|
+
for (const detectorValue of detectorValues) {
|
|
76
|
+
if (detectorValue(s[0])) {
|
|
74
77
|
hasDetectedScript = true;
|
|
75
78
|
break;
|
|
76
79
|
}
|
|
@@ -82,7 +85,9 @@ const handleScriptTransitions = (s, scriptDetectors, caseSensitive, locale, cust
|
|
|
82
85
|
const result = [];
|
|
83
86
|
let currentSegment = chars[0];
|
|
84
87
|
let previousType = "other";
|
|
85
|
-
|
|
88
|
+
const scriptEntries = Object.entries(scriptDetectors);
|
|
89
|
+
for (const scriptEntry of scriptEntries) {
|
|
90
|
+
const [type, detector] = scriptEntry;
|
|
86
91
|
if (detector(chars[0])) {
|
|
87
92
|
previousType = type;
|
|
88
93
|
break;
|
|
@@ -92,7 +97,8 @@ const handleScriptTransitions = (s, scriptDetectors, caseSensitive, locale, cust
|
|
|
92
97
|
for (let index = 1; index < chars.length; index++) {
|
|
93
98
|
const char = chars[index];
|
|
94
99
|
let currentType = "other";
|
|
95
|
-
for (const
|
|
100
|
+
for (const scriptEntry of scriptEntries) {
|
|
101
|
+
const [type, detector] = scriptEntry;
|
|
96
102
|
if (detector(char)) {
|
|
97
103
|
currentType = type;
|
|
98
104
|
break;
|
|
@@ -126,6 +132,18 @@ const handleScriptTransitions = (s, scriptDetectors, caseSensitive, locale, cust
|
|
|
126
132
|
}
|
|
127
133
|
return result.length > 0 ? result : [s];
|
|
128
134
|
};
|
|
135
|
+
const detectAndProcessAcronym = (s, start, knownAcronyms, tokens) => {
|
|
136
|
+
if (knownAcronyms.size === 0) {
|
|
137
|
+
return start;
|
|
138
|
+
}
|
|
139
|
+
for (const acronym of knownAcronyms) {
|
|
140
|
+
if (s.startsWith(acronym, start)) {
|
|
141
|
+
tokens.push(acronym);
|
|
142
|
+
return start + acronym.length;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return start;
|
|
146
|
+
};
|
|
129
147
|
const splitCamelCaseFast = (s, knownAcronyms = /* @__PURE__ */ new Set()) => {
|
|
130
148
|
if (s.length === 0) {
|
|
131
149
|
return [];
|
|
@@ -137,21 +155,14 @@ const splitCamelCaseFast = (s, knownAcronyms = /* @__PURE__ */ new Set()) => {
|
|
|
137
155
|
const tokens = [];
|
|
138
156
|
const width = s.length;
|
|
139
157
|
for (let index = 1; index < width; index++) {
|
|
158
|
+
const newStart = detectAndProcessAcronym(s, start, knownAcronyms, tokens);
|
|
159
|
+
if (newStart !== start) {
|
|
160
|
+
start = newStart;
|
|
161
|
+
index = start - 1;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
140
164
|
const previousCode = s.codePointAt(index - 1);
|
|
141
165
|
const currentCode = s.codePointAt(index);
|
|
142
|
-
if (knownAcronyms.size > 0) {
|
|
143
|
-
for (const acronym of knownAcronyms) {
|
|
144
|
-
if (s.startsWith(acronym, start)) {
|
|
145
|
-
tokens.push(acronym);
|
|
146
|
-
start += acronym.length;
|
|
147
|
-
index = start - 1;
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (index < start) {
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
166
|
const previousIsUpper = previousCode && previousCode < 128 && isUpper(previousCode);
|
|
156
167
|
const currentIsUpper = currentCode && currentCode < 128 && isUpper(currentCode);
|
|
157
168
|
const previousIsLower = previousCode && previousCode < 128 && isLower(previousCode);
|
|
@@ -255,11 +266,26 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
|
|
|
255
266
|
const width_2 = chars2.length;
|
|
256
267
|
const result2 = [];
|
|
257
268
|
let currentSegment2 = chars2[0];
|
|
258
|
-
|
|
259
|
-
let
|
|
269
|
+
const firstChar = chars2[0];
|
|
270
|
+
let previousType;
|
|
271
|
+
if (RE_CYRILLIC.test(firstChar)) {
|
|
272
|
+
previousType = 1;
|
|
273
|
+
} else if (RE_LATIN.test(firstChar)) {
|
|
274
|
+
previousType = 2;
|
|
275
|
+
} else {
|
|
276
|
+
previousType = 0;
|
|
277
|
+
}
|
|
278
|
+
let previousIsUpper2 = firstChar === firstChar.toLocaleUpperCase(locale);
|
|
260
279
|
for (let index = 1; index < width_2; index++) {
|
|
261
280
|
const char = chars2[index];
|
|
262
|
-
|
|
281
|
+
let currentType;
|
|
282
|
+
if (RE_CYRILLIC.test(char)) {
|
|
283
|
+
currentType = 1;
|
|
284
|
+
} else if (RE_LATIN.test(char)) {
|
|
285
|
+
currentType = 2;
|
|
286
|
+
} else {
|
|
287
|
+
currentType = 0;
|
|
288
|
+
}
|
|
263
289
|
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
264
290
|
if (previousType !== currentType && (previousType === 1 || previousType === 2) && (currentType === 1 || currentType === 2) || currentType === previousType && !previousIsUpper2 && isUpperCaseChar) {
|
|
265
291
|
result2.push(currentSegment2);
|
|
@@ -288,28 +314,36 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
|
|
|
288
314
|
if (!RE_GREEK.test(s) && !RE_LATIN.test(s)) {
|
|
289
315
|
return [s];
|
|
290
316
|
}
|
|
291
|
-
const parts =
|
|
317
|
+
const parts = [];
|
|
318
|
+
RE_GREEK_LATIN_SPLIT.lastIndex = 0;
|
|
319
|
+
let greekExecMatch;
|
|
320
|
+
while ((greekExecMatch = RE_GREEK_LATIN_SPLIT.exec(s)) !== null) {
|
|
321
|
+
parts.push(greekExecMatch[0]);
|
|
322
|
+
}
|
|
323
|
+
if (parts.length === 0) {
|
|
324
|
+
parts.push(s);
|
|
325
|
+
}
|
|
292
326
|
const result2 = [];
|
|
293
327
|
const width = parts.length;
|
|
294
328
|
if (width === 1) {
|
|
295
329
|
const part = parts[0];
|
|
296
330
|
if (!part || !RE_GREEK.test(part[0]) || part.length === 1) {
|
|
297
|
-
return [part
|
|
331
|
+
return [part ?? s];
|
|
298
332
|
}
|
|
299
333
|
}
|
|
300
|
-
for (const
|
|
301
|
-
if (!
|
|
334
|
+
for (const greekPart of parts) {
|
|
335
|
+
if (!greekPart) {
|
|
302
336
|
continue;
|
|
303
337
|
}
|
|
304
|
-
if (!RE_GREEK.test(
|
|
305
|
-
result2.push(
|
|
338
|
+
if (!RE_GREEK.test(greekPart[0]) || greekPart.length === 1) {
|
|
339
|
+
result2.push(greekPart);
|
|
306
340
|
continue;
|
|
307
341
|
}
|
|
308
|
-
const partLength =
|
|
309
|
-
let word =
|
|
310
|
-
let previousIsUpper2 =
|
|
342
|
+
const partLength = greekPart.length;
|
|
343
|
+
let word = greekPart[0];
|
|
344
|
+
let previousIsUpper2 = greekPart[0] === greekPart[0].toLocaleUpperCase(locale);
|
|
311
345
|
for (let index = 1; index < partLength; index++) {
|
|
312
|
-
const char =
|
|
346
|
+
const char = greekPart[index];
|
|
313
347
|
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
314
348
|
if (!previousIsUpper2 && isUpperCaseChar) {
|
|
315
349
|
result2.push(word);
|
|
@@ -347,9 +381,10 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
|
|
|
347
381
|
// latin -> japanese
|
|
348
382
|
);
|
|
349
383
|
const result2 = [];
|
|
350
|
-
for (const
|
|
384
|
+
for (const baseSegment of baseSegments) {
|
|
385
|
+
const segment = baseSegment;
|
|
351
386
|
if (segment.length === 1 && particles.has(segment) && result2.length > 0) {
|
|
352
|
-
result2[result2.length - 1]
|
|
387
|
+
result2[result2.length - 1] = result2.at(-1) + segment;
|
|
353
388
|
} else {
|
|
354
389
|
result2.push(segment);
|
|
355
390
|
}
|
|
@@ -374,7 +409,7 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
|
|
|
374
409
|
for (let index = 1; index < width_2; index++) {
|
|
375
410
|
const char = chars2[index];
|
|
376
411
|
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
377
|
-
const isSpecialChar =
|
|
412
|
+
const isSpecialChar = RE_SLOVENIAN_SPECIAL.test(char);
|
|
378
413
|
const nextIsUpper = index < width_2 - 1 && chars2[index + 1] === chars2[index + 1].toLocaleUpperCase(locale);
|
|
379
414
|
if (!previousIsUpper2 && isUpperCaseChar || isSpecialChar && nextIsUpper) {
|
|
380
415
|
result2.push(currentSegment2);
|
|
@@ -540,17 +575,21 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
|
|
|
540
575
|
for (let index = 1; index < width_; index++) {
|
|
541
576
|
const char = chars[index];
|
|
542
577
|
const isUpperCaseChar = char === char.toLocaleUpperCase(locale);
|
|
543
|
-
let
|
|
578
|
+
let acronymLength = 0;
|
|
544
579
|
for (const acronym of knownAcronyms) {
|
|
545
580
|
if (s.startsWith(acronym, index)) {
|
|
546
581
|
result.push(currentSegment, acronym);
|
|
547
|
-
|
|
582
|
+
acronymLength = acronym.length;
|
|
548
583
|
currentSegment = "";
|
|
549
|
-
|
|
584
|
+
const lastAcronymChar = acronym.at(-1);
|
|
585
|
+
if (lastAcronymChar) {
|
|
586
|
+
previousIsUpper = lastAcronymChar === lastAcronymChar.toLocaleUpperCase(locale);
|
|
587
|
+
}
|
|
550
588
|
break;
|
|
551
589
|
}
|
|
552
590
|
}
|
|
553
|
-
if (
|
|
591
|
+
if (acronymLength > 0) {
|
|
592
|
+
index += acronymLength - 1;
|
|
554
593
|
continue;
|
|
555
594
|
}
|
|
556
595
|
if (!previousIsUpper && isUpperCaseChar) {
|
|
@@ -569,20 +608,21 @@ const splitCamelCaseLocale = (s, locale, knownAcronyms) => {
|
|
|
569
608
|
const processTextWithAnsiEmoji = (text, locale, knownAcronyms) => {
|
|
570
609
|
const result = [];
|
|
571
610
|
const segments = RE_FAST_ANSI.test(text) ? text.split(RE_FAST_ANSI).filter(Boolean) : [text];
|
|
572
|
-
for (const
|
|
611
|
+
for (const segment of segments) {
|
|
612
|
+
const seg = segment;
|
|
573
613
|
if (RE_FAST_ANSI.test(seg)) {
|
|
574
614
|
result.push(seg);
|
|
575
615
|
} else {
|
|
576
616
|
const subs = RE_EMOJI.test(seg) ? splitByEmoji(seg).filter(Boolean) : [seg];
|
|
577
|
-
for (const
|
|
578
|
-
if (RE_EMOJI.test(
|
|
579
|
-
result.push(
|
|
617
|
+
for (const emojiSub of subs) {
|
|
618
|
+
if (RE_EMOJI.test(emojiSub)) {
|
|
619
|
+
result.push(emojiSub);
|
|
580
620
|
} else {
|
|
581
621
|
if (locale) {
|
|
582
622
|
const normalizedLocale = locale.toLowerCase().split("-")[0];
|
|
583
|
-
result.push(...splitCamelCaseLocale(
|
|
623
|
+
result.push(...splitCamelCaseLocale(emojiSub, normalizedLocale, knownAcronyms));
|
|
584
624
|
} else {
|
|
585
|
-
result.push(...splitCamelCaseFast(
|
|
625
|
+
result.push(...splitCamelCaseFast(emojiSub, knownAcronyms));
|
|
586
626
|
}
|
|
587
627
|
}
|
|
588
628
|
}
|
|
@@ -604,7 +644,7 @@ const splitByCase = (input, options = {}) => {
|
|
|
604
644
|
stripAnsi: stripAnsiOption = false,
|
|
605
645
|
stripEmoji: stripEmojiOption = false
|
|
606
646
|
} = options;
|
|
607
|
-
const acronymSet = new Set([...knownAcronyms].
|
|
647
|
+
const acronymSet = new Set([...knownAcronyms].toSorted((a, b) => b.length - a.length));
|
|
608
648
|
let cleanedInput = input;
|
|
609
649
|
if (stripAnsiOption) {
|
|
610
650
|
cleanedInput = stripVTControlCharacters(cleanedInput);
|
|
@@ -612,16 +652,95 @@ const splitByCase = (input, options = {}) => {
|
|
|
612
652
|
if (stripEmojiOption) {
|
|
613
653
|
cleanedInput = stripEmoji(cleanedInput);
|
|
614
654
|
}
|
|
615
|
-
|
|
616
|
-
|
|
655
|
+
let separatorRegex;
|
|
656
|
+
if (Array.isArray(separators)) {
|
|
657
|
+
separatorRegex = getSeparatorsRegex(separators);
|
|
658
|
+
} else if (separators instanceof RegExp) {
|
|
659
|
+
separatorRegex = separators;
|
|
660
|
+
} else {
|
|
661
|
+
separatorRegex = RE_SEPARATORS;
|
|
662
|
+
}
|
|
663
|
+
const parts = [];
|
|
664
|
+
let workingInput = cleanedInput;
|
|
665
|
+
const regex = separatorRegex.flags.includes("g") ? separatorRegex : new RegExp(separatorRegex.source, `${separatorRegex.flags}g`);
|
|
666
|
+
while (workingInput.length > 0) {
|
|
667
|
+
const match = regex.exec(workingInput);
|
|
668
|
+
if (!match) {
|
|
669
|
+
if (workingInput === "..") {
|
|
670
|
+
parts.push("..");
|
|
671
|
+
} else if (workingInput === ".") {
|
|
672
|
+
parts.push(".");
|
|
673
|
+
} else if (workingInput.length > 0) {
|
|
674
|
+
parts.push(workingInput);
|
|
675
|
+
}
|
|
676
|
+
break;
|
|
677
|
+
}
|
|
678
|
+
const matchIndex = match.index;
|
|
679
|
+
const matchText = match[0];
|
|
680
|
+
const matchLength = matchText.length;
|
|
681
|
+
const beforeMatch = workingInput.slice(0, matchIndex);
|
|
682
|
+
const afterMatch = workingInput.slice(matchIndex + matchLength);
|
|
683
|
+
if (matchText.startsWith("../")) {
|
|
684
|
+
parts.push("..");
|
|
685
|
+
workingInput = workingInput.slice(matchIndex + 3);
|
|
686
|
+
} else if (matchText.startsWith("./")) {
|
|
687
|
+
parts.push(".");
|
|
688
|
+
workingInput = workingInput.slice(matchIndex + 2);
|
|
689
|
+
} else if (matchIndex === 0 && matchText === "..") {
|
|
690
|
+
parts.push("..");
|
|
691
|
+
workingInput = workingInput.slice(2);
|
|
692
|
+
} else if (matchIndex === 0 && matchText === ".") {
|
|
693
|
+
parts.push(".");
|
|
694
|
+
workingInput = workingInput.slice(1);
|
|
695
|
+
} else {
|
|
696
|
+
if (beforeMatch.length > 0) {
|
|
697
|
+
parts.push(beforeMatch);
|
|
698
|
+
}
|
|
699
|
+
let pos = 0;
|
|
700
|
+
while ((pos = matchText.indexOf("../", pos)) !== -1) {
|
|
701
|
+
parts.push("..");
|
|
702
|
+
pos += 3;
|
|
703
|
+
}
|
|
704
|
+
pos = 0;
|
|
705
|
+
while ((pos = matchText.indexOf("./", pos)) !== -1) {
|
|
706
|
+
if (pos === 0 || matchText[pos - 1] !== ".") {
|
|
707
|
+
parts.push(".");
|
|
708
|
+
}
|
|
709
|
+
pos += 2;
|
|
710
|
+
}
|
|
711
|
+
let remainingAfterMatch = afterMatch;
|
|
712
|
+
while (remainingAfterMatch.startsWith("../")) {
|
|
713
|
+
parts.push("..");
|
|
714
|
+
remainingAfterMatch = remainingAfterMatch.slice(3);
|
|
715
|
+
}
|
|
716
|
+
while (remainingAfterMatch.startsWith("./")) {
|
|
717
|
+
parts.push(".");
|
|
718
|
+
remainingAfterMatch = remainingAfterMatch.slice(2);
|
|
719
|
+
}
|
|
720
|
+
if (remainingAfterMatch === "..") {
|
|
721
|
+
parts.push("..");
|
|
722
|
+
break;
|
|
723
|
+
} else if (remainingAfterMatch === ".") {
|
|
724
|
+
parts.push(".");
|
|
725
|
+
break;
|
|
726
|
+
} else {
|
|
727
|
+
workingInput = remainingAfterMatch;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
regex.lastIndex = 0;
|
|
731
|
+
}
|
|
732
|
+
if (parts.length === 0) {
|
|
733
|
+
const standardParts = cleanedInput.split(separatorRegex).filter(Boolean);
|
|
734
|
+
parts.push(...standardParts);
|
|
735
|
+
}
|
|
617
736
|
let tokens = [];
|
|
618
|
-
for (const
|
|
737
|
+
for (const splitPart of parts) {
|
|
619
738
|
if (handleAnsi || handleEmoji) {
|
|
620
|
-
tokens.push(...processTextWithAnsiEmoji(
|
|
739
|
+
tokens.push(...processTextWithAnsiEmoji(splitPart, locale, acronymSet));
|
|
621
740
|
} else if (locale) {
|
|
622
|
-
tokens.push(...splitCamelCaseLocale(
|
|
741
|
+
tokens.push(...splitCamelCaseLocale(splitPart, locale, acronymSet));
|
|
623
742
|
} else {
|
|
624
|
-
tokens.push(...splitCamelCaseFast(
|
|
743
|
+
tokens.push(...splitCamelCaseFast(splitPart, acronymSet));
|
|
625
744
|
}
|
|
626
745
|
}
|
|
627
746
|
if (normalize) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { C as CaseOptions, T as TitleCase } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { C as CaseOptions, T as TitleCase } from "../packem_shared/types.d-DfgbcNKh.js";
|
|
2
|
+
import "../packem_shared/types.d-BVNv675q.js";
|
|
3
|
+
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
5
4
|
declare function titleCase<T extends string = string>(value?: T, options?: CaseOptions): TitleCase<T>;
|
|
6
|
-
|
|
7
5
|
export { titleCase as default };
|
package/dist/case/title-case.js
CHANGED
|
@@ -2,7 +2,7 @@ import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
|
|
|
2
2
|
import { splitByCase } from './split-by-case.js';
|
|
3
3
|
import upperFirst from './upper-first.js';
|
|
4
4
|
import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
|
|
5
|
-
import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-
|
|
5
|
+
import { n as normalizeGermanEszett } from '../packem_shared/normalize-german-eszett-4p3yKEzn.js';
|
|
6
6
|
|
|
7
7
|
const defaultCacheStore = new LRUCache(1e3);
|
|
8
8
|
function titleCase(value, options) {
|
|
@@ -28,10 +28,8 @@ function titleCase(value, options) {
|
|
|
28
28
|
stripAnsi: options?.stripAnsi,
|
|
29
29
|
stripEmoji: options?.stripEmoji
|
|
30
30
|
}).map((word) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
return upperFirst(options?.locale ? word.toLocaleLowerCase(options.locale) : word.toLowerCase(), { locale: options?.locale });
|
|
31
|
+
const normalized = options?.locale?.startsWith("de") ? normalizeGermanEszett(word) : word;
|
|
32
|
+
return upperFirst(options?.locale ? normalized.toLocaleLowerCase(options.locale) : normalized.toLowerCase(), { locale: options?.locale });
|
|
35
33
|
}).join(" ");
|
|
36
34
|
if (shouldCache && cacheKey) {
|
|
37
35
|
cacheStore.set(cacheKey, result);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { C as CaseOptions, j as TrainCase } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { C as CaseOptions, j as TrainCase } from "../packem_shared/types.d-DfgbcNKh.js";
|
|
2
|
+
import "../packem_shared/types.d-BVNv675q.js";
|
|
3
|
+
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
5
4
|
declare const trainCase: <T extends string = string>(value?: T, options?: CaseOptions) => TrainCase<T>;
|
|
6
|
-
|
|
7
5
|
export { trainCase as default };
|
package/dist/case/train-case.js
CHANGED
|
@@ -2,7 +2,7 @@ import LRUCache from '../packem_shared/LRUCache-3r3SovvR.js';
|
|
|
2
2
|
import { splitByCase } from './split-by-case.js';
|
|
3
3
|
import upperFirst from './upper-first.js';
|
|
4
4
|
import { g as generateCacheKey } from '../packem_shared/generate-cache-key-DdayDfjV.js';
|
|
5
|
-
import joinSegments from '../packem_shared/joinSegments-
|
|
5
|
+
import joinSegments from '../packem_shared/joinSegments-CvxSgKz0.js';
|
|
6
6
|
|
|
7
7
|
const defaultCacheStore = new LRUCache(1e3);
|
|
8
8
|
const trainCase = (value, options) => {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { L as LocaleOptions, U as UpperFirst } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { L as LocaleOptions, U as UpperFirst } from "../packem_shared/types.d-DfgbcNKh.js";
|
|
2
|
+
import "../packem_shared/types.d-BVNv675q.js";
|
|
3
|
+
import "../packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
5
4
|
declare const upperFirst: <T extends string = string>(value?: T, options?: LocaleOptions) => UpperFirst<T>;
|
|
6
|
-
|
|
7
5
|
export { upperFirst as default };
|
package/dist/closest-string.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
interface ClosestStringOptions {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
caseSensitive?: boolean;
|
|
3
|
+
compareFn?: (a: string, b: string) => number;
|
|
4
4
|
}
|
|
5
5
|
declare const closestString: (givenWord: string, possibleWords: ReadonlyArray<string>, options?: ClosestStringOptions) => string | undefined;
|
|
6
|
-
|
|
7
|
-
export { closestString };
|
|
8
|
-
export type { ClosestStringOptions };
|
|
6
|
+
export { ClosestStringOptions, closestString };
|
package/dist/closest-string.js
CHANGED
|
@@ -2,18 +2,15 @@ import { distance } from './packem_shared/closest-IHuSvnSn.js';
|
|
|
2
2
|
|
|
3
3
|
const closestString = (givenWord, possibleWords, options) => {
|
|
4
4
|
if (possibleWords.length === 0) {
|
|
5
|
-
throw new TypeError(
|
|
6
|
-
"When using closestString(), the possibleWords array must contain at least one word"
|
|
7
|
-
);
|
|
5
|
+
throw new TypeError("When using closestString(), the possibleWords array must contain at least one word");
|
|
8
6
|
}
|
|
9
7
|
const { caseSensitive, compareFn: compareFunction = distance } = { ...options };
|
|
10
|
-
|
|
11
|
-
givenWord = givenWord.toLowerCase();
|
|
12
|
-
}
|
|
8
|
+
const normalizedGivenWord = caseSensitive ? givenWord : givenWord.toLowerCase();
|
|
13
9
|
let nearestWord = possibleWords[0] ?? void 0;
|
|
14
10
|
let closestStringDistance = Infinity;
|
|
15
|
-
for (const
|
|
16
|
-
const
|
|
11
|
+
for (const possibleWord of possibleWords) {
|
|
12
|
+
const each = possibleWord;
|
|
13
|
+
const distance = caseSensitive ? compareFunction(normalizedGivenWord, each) : compareFunction(normalizedGivenWord, each.toLowerCase());
|
|
17
14
|
if (distance < closestStringDistance) {
|
|
18
15
|
nearestWord = each;
|
|
19
16
|
closestStringDistance = distance;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
interface CompareSimilarityOptions {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
caseSensitive?: boolean;
|
|
3
|
+
compareFn?: (a: string, b: string) => number;
|
|
4
4
|
}
|
|
5
5
|
declare const compareSimilarity: (givenWord: string, options?: CompareSimilarityOptions) => (a: string, b: string) => number;
|
|
6
|
-
|
|
7
|
-
export { compareSimilarity };
|
|
8
|
-
export type { CompareSimilarityOptions };
|
|
6
|
+
export { CompareSimilarityOptions, compareSimilarity };
|
|
@@ -5,8 +5,8 @@ const compareSimilarity = (givenWord, options) => {
|
|
|
5
5
|
if (options?.caseSensitive) {
|
|
6
6
|
return (a, b) => compareFunction(givenWord, a) - compareFunction(givenWord, b);
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
return (a, b) => compareFunction(
|
|
8
|
+
const normalizedGivenWord = givenWord.toLowerCase();
|
|
9
|
+
return (a, b) => compareFunction(normalizedGivenWord, a.toLowerCase()) - compareFunction(normalizedGivenWord, b.toLowerCase());
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export { compareSimilarity };
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
interface StringTruncatedWidthOptions {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
ambiguousIsNarrow?: boolean;
|
|
3
|
+
ansiWidth?: number;
|
|
4
|
+
controlWidth?: number;
|
|
5
|
+
countAnsiEscapeCodes?: boolean;
|
|
6
|
+
ellipsis?: string;
|
|
7
|
+
ellipsisWidth?: number;
|
|
8
|
+
emojiWidth?: number;
|
|
9
|
+
fullWidth?: number;
|
|
10
|
+
halfWidth?: number;
|
|
11
|
+
limit?: number;
|
|
12
|
+
regularWidth?: number;
|
|
13
|
+
tabWidth?: number;
|
|
14
|
+
wideWidth?: number;
|
|
15
15
|
}
|
|
16
16
|
interface StringTruncatedWidthResult {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
ellipsed: boolean;
|
|
18
|
+
index: number;
|
|
19
|
+
truncated: boolean;
|
|
20
|
+
width: number;
|
|
21
21
|
}
|
|
22
22
|
declare const getStringTruncatedWidth: (input: string, options?: StringTruncatedWidthOptions) => StringTruncatedWidthResult;
|
|
23
|
-
|
|
24
|
-
export { getStringTruncatedWidth };
|
|
25
|
-
export type { StringTruncatedWidthOptions, StringTruncatedWidthResult };
|
|
23
|
+
export { StringTruncatedWidthOptions, StringTruncatedWidthResult, getStringTruncatedWidth };
|
|
@@ -1,36 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function isAmbiguous(x) {
|
|
4
|
-
return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
|
|
5
|
-
}
|
|
6
|
-
function isFullWidth(x) {
|
|
7
|
-
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
8
|
-
}
|
|
9
|
-
function isWide(x) {
|
|
10
|
-
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x >= 94192 && x <= 94198 || x >= 94208 && x <= 101589 || x >= 101631 && x <= 101662 || x >= 101760 && x <= 101874 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128728 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129674 || x >= 129678 && x <= 129734 || x === 129736 || x >= 129741 && x <= 129756 || x >= 129759 && x <= 129770 || x >= 129775 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
11
|
-
}
|
|
12
|
-
function getCategory(x) {
|
|
13
|
-
if (isAmbiguous(x)) return "ambiguous";
|
|
14
|
-
if (isFullWidth(x)) return "fullwidth";
|
|
15
|
-
if (x === 8361 || x >= 65377 && x <= 65470 || x >= 65474 && x <= 65479 || x >= 65482 && x <= 65487 || x >= 65490 && x <= 65495 || x >= 65498 && x <= 65500 || x >= 65512 && x <= 65518) {
|
|
16
|
-
return "halfwidth";
|
|
17
|
-
}
|
|
18
|
-
if (x >= 32 && x <= 126 || x === 162 || x === 163 || x === 165 || x === 166 || x === 172 || x === 175 || x >= 10214 && x <= 10221 || x === 10629 || x === 10630) {
|
|
19
|
-
return "narrow";
|
|
20
|
-
}
|
|
21
|
-
if (isWide(x)) return "wide";
|
|
22
|
-
return "neutral";
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function validate(codePoint) {
|
|
26
|
-
if (!Number.isSafeInteger(codePoint)) {
|
|
27
|
-
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function eastAsianWidthType(codePoint) {
|
|
31
|
-
validate(codePoint);
|
|
32
|
-
return getCategory(codePoint);
|
|
33
|
-
}
|
|
1
|
+
import { eastAsianWidthType } from './packem_shared/eastAsianWidthType-SD3YniiT.js';
|
|
2
|
+
import { g as RE_ANSI, h as RE_CONTROL, i as RE_EMOJI } from './packem_shared/constants-BsZS5f0z.js';
|
|
34
3
|
|
|
35
4
|
const charWidthCache = /* @__PURE__ */ new Map();
|
|
36
5
|
const RE_LATIN_CHARS = /(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { StringTruncatedWidthOptions } from
|
|
2
|
-
|
|
1
|
+
import { StringTruncatedWidthOptions } from "./get-string-truncated-width.js";
|
|
3
2
|
type StringWidthOptions = Omit<StringTruncatedWidthOptions, "ellipsis" | "ellipsisWidth" | "limit">;
|
|
4
3
|
declare const getStringWidth: (input: string, options?: StringWidthOptions) => number;
|
|
5
|
-
|
|
6
|
-
export { getStringWidth };
|
|
7
|
-
export type { StringWidthOptions };
|
|
4
|
+
export { StringWidthOptions, getStringWidth };
|