@visulima/string 3.0.0-alpha.7 → 3.0.0-alpha.9
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 +39 -0
- package/LICENSE.md +54 -0
- package/README.md +8 -2
- package/dist/align-text.js +7 -5
- package/dist/case/camel-case.js +7 -7
- package/dist/case/capital-case.js +3 -3
- package/dist/case/flip-case.js +1 -1
- package/dist/case/identify-case.js +2 -1
- package/dist/case/index.d.ts +1 -1
- package/dist/case/index.js +1 -1
- package/dist/case/kebab-case.js +3 -3
- package/dist/case/pascal-case.js +3 -3
- package/dist/case/sentence-case.js +7 -7
- package/dist/case/split-by-case.js +46 -30
- package/dist/case/title-case.js +3 -5
- package/dist/case/train-case.js +1 -1
- package/dist/closest-string.js +4 -5
- package/dist/compare-similarity.js +2 -2
- package/dist/get-string-truncated-width.js +2 -114
- package/dist/index.d.ts +7 -2
- package/dist/index.js +10 -5
- package/dist/outdent.js +6 -14
- package/dist/packem_shared/{closestN-Cvsw0Fue.js → closestN-DUsjgiXb.js} +4 -3
- package/dist/packem_shared/{constants-D5qaproB.js → constants-BsZS5f0z.js} +1 -1
- package/dist/packem_shared/direction-C9gfWWTK.js +16 -0
- package/dist/packem_shared/eastAsianWidthType-SD3YniiT.js +20 -0
- package/dist/packem_shared/indent-D3DSCa6s.js +33 -0
- package/dist/packem_shared/isFullwidthCodePoint-IFXZxNjq.js +10 -0
- package/dist/packem_shared/{joinSegments-BStLas0c.js → joinSegments-CvxSgKz0.js} +1 -1
- package/dist/packem_shared/lookup-BE8lEqy4.js +104 -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-BVlxk27d.js → replaceString-Ce8X2ZQ-.js} +11 -9
- package/dist/packem_shared/stripIndent-D_TRjxZ_.js +20 -0
- package/dist/packem_shared/{transliterate-DGlx-woj.js → transliterate-CKt9VK7D.js} +10 -10
- package/dist/slice.js +9 -7
- package/dist/slugify.js +1 -1
- package/dist/truncate.js +28 -30
- package/dist/utilities.js +6 -8
- package/dist/word-wrap.js +20 -18
- package/package.json +1 -4
- package/dist/packem_shared/direction-BVhR8MOQ.js +0 -10
|
@@ -1,117 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const ambiguousRanges = [161, 161, 164, 164, 167, 168, 170, 170, 173, 174, 176, 180, 182, 186, 188, 191, 198, 198, 208, 208, 215, 216, 222, 225, 230, 230, 232, 234, 236, 237, 240, 240, 242, 243, 247, 250, 252, 252, 254, 254, 257, 257, 273, 273, 275, 275, 283, 283, 294, 295, 299, 299, 305, 307, 312, 312, 319, 322, 324, 324, 328, 331, 333, 333, 338, 339, 358, 359, 363, 363, 462, 462, 464, 464, 466, 466, 468, 468, 470, 470, 472, 472, 474, 474, 476, 476, 593, 593, 609, 609, 708, 708, 711, 711, 713, 715, 717, 717, 720, 720, 728, 731, 733, 733, 735, 735, 768, 879, 913, 929, 931, 937, 945, 961, 963, 969, 1025, 1025, 1040, 1103, 1105, 1105, 8208, 8208, 8211, 8214, 8216, 8217, 8220, 8221, 8224, 8226, 8228, 8231, 8240, 8240, 8242, 8243, 8245, 8245, 8251, 8251, 8254, 8254, 8308, 8308, 8319, 8319, 8321, 8324, 8364, 8364, 8451, 8451, 8453, 8453, 8457, 8457, 8467, 8467, 8470, 8470, 8481, 8482, 8486, 8486, 8491, 8491, 8531, 8532, 8539, 8542, 8544, 8555, 8560, 8569, 8585, 8585, 8592, 8601, 8632, 8633, 8658, 8658, 8660, 8660, 8679, 8679, 8704, 8704, 8706, 8707, 8711, 8712, 8715, 8715, 8719, 8719, 8721, 8721, 8725, 8725, 8730, 8730, 8733, 8736, 8739, 8739, 8741, 8741, 8743, 8748, 8750, 8750, 8756, 8759, 8764, 8765, 8776, 8776, 8780, 8780, 8786, 8786, 8800, 8801, 8804, 8807, 8810, 8811, 8814, 8815, 8834, 8835, 8838, 8839, 8853, 8853, 8857, 8857, 8869, 8869, 8895, 8895, 8978, 8978, 9312, 9449, 9451, 9547, 9552, 9587, 9600, 9615, 9618, 9621, 9632, 9633, 9635, 9641, 9650, 9651, 9654, 9655, 9660, 9661, 9664, 9665, 9670, 9672, 9675, 9675, 9678, 9681, 9698, 9701, 9711, 9711, 9733, 9734, 9737, 9737, 9742, 9743, 9756, 9756, 9758, 9758, 9792, 9792, 9794, 9794, 9824, 9825, 9827, 9829, 9831, 9834, 9836, 9837, 9839, 9839, 9886, 9887, 9919, 9919, 9926, 9933, 9935, 9939, 9941, 9953, 9955, 9955, 9960, 9961, 9963, 9969, 9972, 9972, 9974, 9977, 9979, 9980, 9982, 9983, 10045, 10045, 10102, 10111, 11094, 11097, 12872, 12879, 57344, 63743, 65024, 65039, 65533, 65533, 127232, 127242, 127248, 127277, 127280, 127337, 127344, 127373, 127375, 127376, 127387, 127404, 917760, 917999, 983040, 1048573, 1048576, 1114109];
|
|
4
|
-
const fullwidthRanges = [12288, 12288, 65281, 65376, 65504, 65510];
|
|
5
|
-
const halfwidthRanges = [8361, 8361, 65377, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65512, 65518];
|
|
6
|
-
const narrowRanges = [32, 126, 162, 163, 165, 166, 172, 172, 175, 175, 10214, 10221, 10629, 10630];
|
|
7
|
-
const wideRanges = [4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203, 9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871, 9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934, 9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981, 9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067, 10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036, 11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272, 12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686, 12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360, 43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126, 65128, 65131, 94176, 94180, 94192, 94198, 94208, 101589, 101631, 101662, 101760, 101874, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110882, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110951, 110960, 111355, 119552, 119638, 119648, 119670, 126980, 126980, 127183, 127183, 127374, 127374, 127377, 127386, 127488, 127490, 127504, 127547, 127552, 127560, 127568, 127569, 127584, 127589, 127744, 127776, 127789, 127797, 127799, 127868, 127870, 127891, 127904, 127946, 127951, 127955, 127968, 127984, 127988, 127988, 127992, 128062, 128064, 128064, 128066, 128252, 128255, 128317, 128331, 128334, 128336, 128359, 128378, 128378, 128405, 128406, 128420, 128420, 128507, 128591, 128640, 128709, 128716, 128716, 128720, 128722, 128725, 128728, 128732, 128735, 128747, 128748, 128756, 128764, 128992, 129003, 129008, 129008, 129292, 129338, 129340, 129349, 129351, 129535, 129648, 129660, 129664, 129674, 129678, 129734, 129736, 129736, 129741, 129756, 129759, 129770, 129775, 129784, 131072, 196605, 196608, 262141];
|
|
8
|
-
|
|
9
|
-
const isInRange = (ranges, codePoint) => {
|
|
10
|
-
let low = 0;
|
|
11
|
-
let high = Math.floor(ranges.length / 2) - 1;
|
|
12
|
-
while (low <= high) {
|
|
13
|
-
const mid = Math.floor((low + high) / 2);
|
|
14
|
-
const i = mid * 2;
|
|
15
|
-
if (codePoint < ranges[i]) {
|
|
16
|
-
high = mid - 1;
|
|
17
|
-
} else if (codePoint > ranges[i + 1]) {
|
|
18
|
-
low = mid + 1;
|
|
19
|
-
} else {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const minimumAmbiguousCodePoint = ambiguousRanges[0];
|
|
27
|
-
const maximumAmbiguousCodePoint = ambiguousRanges.at(-1);
|
|
28
|
-
const minimumFullWidthCodePoint = fullwidthRanges[0];
|
|
29
|
-
const maximumFullWidthCodePoint = fullwidthRanges.at(-1);
|
|
30
|
-
const minimumHalfWidthCodePoint = halfwidthRanges[0];
|
|
31
|
-
const maximumHalfWidthCodePoint = halfwidthRanges.at(-1);
|
|
32
|
-
const minimumNarrowCodePoint = narrowRanges[0];
|
|
33
|
-
const maximumNarrowCodePoint = narrowRanges.at(-1);
|
|
34
|
-
const minimumWideCodePoint = wideRanges[0];
|
|
35
|
-
const maximumWideCodePoint = wideRanges.at(-1);
|
|
36
|
-
const commonCjkCodePoint = 19968;
|
|
37
|
-
const [wideFastPathStart, wideFastPathEnd] = findWideFastPathRange(wideRanges);
|
|
38
|
-
function findWideFastPathRange(ranges) {
|
|
39
|
-
let fastPathStart = ranges[0];
|
|
40
|
-
let fastPathEnd = ranges[1];
|
|
41
|
-
for (let index = 0; index < ranges.length; index += 2) {
|
|
42
|
-
const start = ranges[index];
|
|
43
|
-
const end = ranges[index + 1];
|
|
44
|
-
if (commonCjkCodePoint >= start && commonCjkCodePoint <= end) {
|
|
45
|
-
return [start, end];
|
|
46
|
-
}
|
|
47
|
-
if (end - start > fastPathEnd - fastPathStart) {
|
|
48
|
-
fastPathStart = start;
|
|
49
|
-
fastPathEnd = end;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return [fastPathStart, fastPathEnd];
|
|
53
|
-
}
|
|
54
|
-
const isAmbiguous = (codePoint) => {
|
|
55
|
-
if (codePoint < minimumAmbiguousCodePoint || codePoint > maximumAmbiguousCodePoint) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
return isInRange(ambiguousRanges, codePoint);
|
|
59
|
-
};
|
|
60
|
-
const isFullWidth = (codePoint) => {
|
|
61
|
-
if (codePoint < minimumFullWidthCodePoint || codePoint > maximumFullWidthCodePoint) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
return isInRange(fullwidthRanges, codePoint);
|
|
65
|
-
};
|
|
66
|
-
const isHalfWidth = (codePoint) => {
|
|
67
|
-
if (codePoint < minimumHalfWidthCodePoint || codePoint > maximumHalfWidthCodePoint) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
return isInRange(halfwidthRanges, codePoint);
|
|
71
|
-
};
|
|
72
|
-
const isNarrow = (codePoint) => {
|
|
73
|
-
if (codePoint < minimumNarrowCodePoint || codePoint > maximumNarrowCodePoint) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
return isInRange(narrowRanges, codePoint);
|
|
77
|
-
};
|
|
78
|
-
const isWide = (codePoint) => {
|
|
79
|
-
if (codePoint >= wideFastPathStart && codePoint <= wideFastPathEnd) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
if (codePoint < minimumWideCodePoint || codePoint > maximumWideCodePoint) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return isInRange(wideRanges, codePoint);
|
|
86
|
-
};
|
|
87
|
-
function getCategory(codePoint) {
|
|
88
|
-
if (isAmbiguous(codePoint)) {
|
|
89
|
-
return "ambiguous";
|
|
90
|
-
}
|
|
91
|
-
if (isFullWidth(codePoint)) {
|
|
92
|
-
return "fullwidth";
|
|
93
|
-
}
|
|
94
|
-
if (isHalfWidth(codePoint)) {
|
|
95
|
-
return "halfwidth";
|
|
96
|
-
}
|
|
97
|
-
if (isNarrow(codePoint)) {
|
|
98
|
-
return "narrow";
|
|
99
|
-
}
|
|
100
|
-
if (isWide(codePoint)) {
|
|
101
|
-
return "wide";
|
|
102
|
-
}
|
|
103
|
-
return "neutral";
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function validate(codePoint) {
|
|
107
|
-
if (!Number.isSafeInteger(codePoint)) {
|
|
108
|
-
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function eastAsianWidthType(codePoint) {
|
|
112
|
-
validate(codePoint);
|
|
113
|
-
return getCategory(codePoint);
|
|
114
|
-
}
|
|
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';
|
|
115
3
|
|
|
116
4
|
const charWidthCache = /* @__PURE__ */ new Map();
|
|
117
5
|
const RE_LATIN_CHARS = /(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,10 +22,14 @@ export { default as upperFirst } from "./case/upper-first.js";
|
|
|
22
22
|
export { joinSegments } from "./case/index.js";
|
|
23
23
|
export { type ClosestStringOptions, closestString } from "./closest-string.js";
|
|
24
24
|
export { type CompareSimilarityOptions, compareSimilarity } from "./compare-similarity.js";
|
|
25
|
+
export { type Options as EastAsianWidthOptions, type WidthType as EastAsianWidthType, eastAsianWidth, eastAsianWidthType } from 'get-east-asian-width';
|
|
25
26
|
import { TruncateOptions } from "./truncate.js";
|
|
26
27
|
export { truncate } from "./truncate.js";
|
|
27
28
|
export { type StringTruncatedWidthOptions, type StringTruncatedWidthResult, getStringTruncatedWidth } from "./get-string-truncated-width.js";
|
|
28
29
|
export { type StringWidthOptions, getStringWidth } from "./get-string-width.js";
|
|
30
|
+
export { type Options as IndentOptions, default as indent } from 'indent-string';
|
|
31
|
+
export { default as redent } from 'redent';
|
|
32
|
+
export { dedent, default as stripIndent } from 'strip-indent';
|
|
29
33
|
export { type Outdent, type Options as OutdentOptions, outdent } from "./outdent.js";
|
|
30
34
|
import { O as OptionReplaceArray, a as IntervalArray, b as OptionsTransliterate } from "./packem_shared/types.d-BVNv675q.js";
|
|
31
35
|
export { type A as All, type c as Any, type C as CharAt, type d as Charmap, type e as Concat, type E as EndsWith, type f as Includes, type g as Interval, type h as IsBooleanLiteral, type i as IsNumberLiteral, type I as IsStringLiteral, type j as IsStringLiteralArray, type J as Join, type L as Length, type M as Math, type N as NodeLocale, type k as OptionReplaceCombined, type l as OptionReplaceObject, type P as PadEnd, type m as PadStart, type R as Repeat, type n as Replace, type o as ReplaceAll, type p as Reverse, type q as Slice, type S as SlugifyOptions, type r as Split, type s as StartsWith, type T as ToLowerCase, type t as ToUpperCase, type u as Trim, type v as TrimEnd, type w as TrimStart } from "./packem_shared/types.d-BVNv675q.js";
|
|
@@ -37,10 +41,11 @@ export { type WordWrapOptions, WrapMode, wordWrap } from "./word-wrap.js";
|
|
|
37
41
|
export { closest, distance } from 'fastest-levenshtein';
|
|
38
42
|
import "./packem_shared/lru-cache.d-BsP6kbVJ.js";
|
|
39
43
|
declare const countOccurrences: (value: string, substring: string) => number;
|
|
40
|
-
declare const direction: (value
|
|
44
|
+
declare const direction: (value?: string) => "rtl" | "ltr" | "neutral";
|
|
41
45
|
declare const excerpt: (html: string, limit: number, options?: ExcerptOptions) => string;
|
|
42
46
|
type ExcerptOptions = Omit<TruncateOptions, "position">;
|
|
47
|
+
declare const isFullwidthCodePoint: (codePoint: number) => boolean;
|
|
43
48
|
declare const closestN: (string_: string, array: ReadonlyArray<string>, n: number) => (string | undefined)[];
|
|
44
49
|
declare const replaceString: (source: string, searches: OptionReplaceArray, ignoreRanges: IntervalArray) => string;
|
|
45
50
|
declare const transliterate: (source: string, options?: OptionsTransliterate) => string;
|
|
46
|
-
export { type ExcerptOptions, type IntervalArray, type OptionReplaceArray, type OptionsTransliterate, type TruncateOptions, closestN, countOccurrences, direction, excerpt, replaceString, transliterate };
|
|
51
|
+
export { type ExcerptOptions, type IntervalArray, type OptionReplaceArray, type OptionsTransliterate, type TruncateOptions, closestN, countOccurrences, direction, excerpt, isFullwidthCodePoint, replaceString, transliterate };
|
package/dist/index.js
CHANGED
|
@@ -18,22 +18,27 @@ export { splitByCase } from './case/split-by-case.js';
|
|
|
18
18
|
export { default as titleCase } from './case/title-case.js';
|
|
19
19
|
export { default as trainCase } from './case/train-case.js';
|
|
20
20
|
export { default as upperFirst } from './case/upper-first.js';
|
|
21
|
-
export { default as joinSegments } from './packem_shared/joinSegments-
|
|
21
|
+
export { default as joinSegments } from './packem_shared/joinSegments-CvxSgKz0.js';
|
|
22
22
|
export { closestString } from './closest-string.js';
|
|
23
23
|
export { compareSimilarity } from './compare-similarity.js';
|
|
24
24
|
export { countOccurrences } from './packem_shared/countOccurrences-CS9XprQN.js';
|
|
25
|
-
export { direction } from './packem_shared/direction-
|
|
25
|
+
export { direction } from './packem_shared/direction-C9gfWWTK.js';
|
|
26
26
|
export { excerpt } from './packem_shared/excerpt-COsVNttN.js';
|
|
27
27
|
export { getStringTruncatedWidth } from './get-string-truncated-width.js';
|
|
28
28
|
export { getStringWidth } from './get-string-width.js';
|
|
29
|
-
export {
|
|
29
|
+
export { default as isFullwidthCodePoint } from './packem_shared/isFullwidthCodePoint-IFXZxNjq.js';
|
|
30
|
+
export { closestN } from './packem_shared/closestN-DUsjgiXb.js';
|
|
30
31
|
export { outdent } from './outdent.js';
|
|
31
|
-
export { default as replaceString } from './packem_shared/replaceString-
|
|
32
|
+
export { default as replaceString } from './packem_shared/replaceString-Ce8X2ZQ-.js';
|
|
32
33
|
export { slice } from './slice.js';
|
|
33
34
|
export { default as slugify } from './slugify.js';
|
|
34
|
-
export { default as transliterate } from './packem_shared/transliterate-
|
|
35
|
+
export { default as transliterate } from './packem_shared/transliterate-CKt9VK7D.js';
|
|
35
36
|
export { truncate } from './truncate.js';
|
|
36
37
|
export { escapeRegExp, findStringOccurrences, hasChinese, hasPunctuationOrSpace, inRange } from './utilities.js';
|
|
37
38
|
export { wordSimilaritySort } from './word-similarity-sort.js';
|
|
38
39
|
export { WrapMode, wordWrap } from './word-wrap.js';
|
|
40
|
+
export { default as indent } from './packem_shared/indent-D3DSCa6s.js';
|
|
41
|
+
export { default as redent } from './packem_shared/redent-DSb1IJWn.js';
|
|
42
|
+
export { dedent, default as stripIndent } from './packem_shared/stripIndent-D_TRjxZ_.js';
|
|
39
43
|
export { closest, distance } from './packem_shared/closest-IHuSvnSn.js';
|
|
44
|
+
export { eastAsianWidth, eastAsianWidthType } from './packem_shared/eastAsianWidthType-SD3YniiT.js';
|
package/dist/outdent.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { a as RE_LEADING_NEWLINE, b as RE_TRAILING_NEWLINE, c as RE_ONLY_WHITESPACE_WITH_AT_LEAST_ONE_NEWLINE, d as RE_STARTS_WITH_NEWLINE_OR_IS_EMPTY, e as RE_MATCH_NEWLINES, f as RE_DETECT_INDENTATION } from './packem_shared/constants-
|
|
1
|
+
import { a as RE_LEADING_NEWLINE, b as RE_TRAILING_NEWLINE, c as RE_ONLY_WHITESPACE_WITH_AT_LEAST_ONE_NEWLINE, d as RE_STARTS_WITH_NEWLINE_OR_IS_EMPTY, e as RE_MATCH_NEWLINES, f as RE_DETECT_INDENTATION } from './packem_shared/constants-BsZS5f0z.js';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const extend = (target, source) => {
|
|
6
|
-
for (const property of Object.keys(source)) {
|
|
7
|
-
target[property] = source[property];
|
|
8
|
-
}
|
|
9
|
-
return target;
|
|
10
|
-
};
|
|
3
|
+
const has = (object, property) => Object.hasOwn(object, property);
|
|
4
|
+
const extend = (target, source) => Object.assign(target, source);
|
|
11
5
|
const internalOutdentArray = (strings, firstInterpolatedValueSetsIndentationLevel, options) => {
|
|
12
6
|
if (strings.length === 0) {
|
|
13
7
|
return [];
|
|
@@ -19,15 +13,13 @@ const internalOutdentArray = (strings, firstInterpolatedValueSetsIndentationLeve
|
|
|
19
13
|
}
|
|
20
14
|
const reSource = String.raw`(\r\n|\r|\n).{0,${indentationLevel}}`;
|
|
21
15
|
const reMatchIndent = new RegExp(reSource, "g");
|
|
22
|
-
|
|
23
|
-
strings = strings.slice(1);
|
|
24
|
-
}
|
|
16
|
+
const processedStrings = firstInterpolatedValueSetsIndentationLevel ? strings.slice(1) : strings;
|
|
25
17
|
const { newline, trimLeadingNewline, trimTrailingNewline } = options;
|
|
26
18
|
const normalizeNewlines = typeof newline === "string";
|
|
27
|
-
const l =
|
|
19
|
+
const l = processedStrings.length;
|
|
28
20
|
const outdentedStrings = Array.from({ length: l });
|
|
29
21
|
for (let index = 0; index < l; index++) {
|
|
30
|
-
let v =
|
|
22
|
+
let v = processedStrings[index];
|
|
31
23
|
v = v.replace(reMatchIndent, "$1");
|
|
32
24
|
if (index === 0 && trimLeadingNewline) {
|
|
33
25
|
v = v.replace(RE_LEADING_NEWLINE, "");
|
|
@@ -2,9 +2,10 @@ import { distance } from './closest-IHuSvnSn.js';
|
|
|
2
2
|
export { closest } from './closest-IHuSvnSn.js';
|
|
3
3
|
|
|
4
4
|
const closestN = (string_, array, n) => {
|
|
5
|
-
const distances = Array.from({ length: n }
|
|
6
|
-
const values = Array.from({ length: n }
|
|
7
|
-
for (const
|
|
5
|
+
const distances = Array.from({ length: n }).fill(Infinity);
|
|
6
|
+
const values = Array.from({ length: n }).fill(void 0);
|
|
7
|
+
for (const element of array) {
|
|
8
|
+
const candidateValue = element;
|
|
8
9
|
let currentDistance = distance(string_, candidateValue);
|
|
9
10
|
let currentValue = candidateValue;
|
|
10
11
|
for (let index = 0; index < n; index += 1) {
|
|
@@ -92,4 +92,4 @@ const RE_TIBETAN = new RegExp("\\p{Script=Tibetan}", "u");
|
|
|
92
92
|
const RE_UZBEK_LATIN_MODIFIER = /[\u02BB\u02BC\u0027]/u;
|
|
93
93
|
const stripEmoji = (stringValue) => stringValue.replace(RE_EMOJI, "");
|
|
94
94
|
|
|
95
|
-
export {
|
|
95
|
+
export { RE_GUJARATI as A, RE_GURMUKHI as B, RE_KANNADA as C, RE_TAMIL as D, RE_TELUGU as E, RE_MALAYALAM as F, RE_SINHALA as G, RE_THAI as H, RE_LAO as I, RE_TIBETAN as J, RE_MYANMAR as K, RE_ETHIOPIC as L, RE_KHMER as M, RE_ORIYA as N, ESCAPES as O, ANSI_ESCAPE_LINK as P, ANSI_SGR_TERMINATOR as Q, RE_FAST_ANSI as R, ANSI_ESCAPE_BELL as S, ANSI_CSI as T, RE_ESCAPE_PATTERN as U, ANSI_RESET_CODES as V, END_CODE as W, RE_ZERO_WIDTH as X, RE_LEADING_NEWLINE as a, RE_TRAILING_NEWLINE as b, RE_ONLY_WHITESPACE_WITH_AT_LEAST_ONE_NEWLINE as c, RE_STARTS_WITH_NEWLINE_OR_IS_EMPTY as d, RE_MATCH_NEWLINES as e, RE_DETECT_INDENTATION as f, RE_ANSI as g, RE_CONTROL as h, RE_EMOJI as i, RE_VALID_ANSI_PAIRS as j, RE_VALID_HYPERLINKS as k, RE_CYRILLIC as l, RE_LATIN as m, RE_GREEK as n, RE_GREEK_LATIN_SPLIT as o, RE_UZBEK_LATIN_MODIFIER as p, RE_KATAKANA as q, RE_KANJI as r, stripEmoji as s, RE_HIRAGANA as t, RE_HANGUL as u, RE_HEBREW as v, RE_ARABIC as w, RE_SEPARATORS as x, RE_DEVANAGARI as y, RE_BENGALI as z };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const rtlRange = "֑-߿יִ-﷽ﹰ-ﻼ";
|
|
2
|
+
const ltrRange = "A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--";
|
|
3
|
+
const rtl = new RegExp(`^[^${ltrRange}]*[${rtlRange}]`);
|
|
4
|
+
const ltr = new RegExp(`^[^${rtlRange}]*[${ltrRange}]`);
|
|
5
|
+
const direction = (value = "") => {
|
|
6
|
+
const source = value;
|
|
7
|
+
if (rtl.test(source)) {
|
|
8
|
+
return "rtl";
|
|
9
|
+
}
|
|
10
|
+
if (ltr.test(source)) {
|
|
11
|
+
return "ltr";
|
|
12
|
+
}
|
|
13
|
+
return "neutral";
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { direction };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { i as isFullWidth, a as isWide, b as isAmbiguous, g as getCategory } from './lookup-BE8lEqy4.js';
|
|
2
|
+
|
|
3
|
+
function validate(codePoint) {
|
|
4
|
+
if (!Number.isSafeInteger(codePoint)) {
|
|
5
|
+
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function eastAsianWidthType(codePoint) {
|
|
9
|
+
validate(codePoint);
|
|
10
|
+
return getCategory(codePoint);
|
|
11
|
+
}
|
|
12
|
+
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
13
|
+
validate(codePoint);
|
|
14
|
+
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
15
|
+
return 2;
|
|
16
|
+
}
|
|
17
|
+
return 1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { isFullWidth as _isFullWidth, isWide as _isWide, eastAsianWidth, eastAsianWidthType };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function indentString(string, count = 1, options = {}) {
|
|
2
|
+
const {
|
|
3
|
+
indent = " ",
|
|
4
|
+
includeEmptyLines = false
|
|
5
|
+
} = options;
|
|
6
|
+
if (typeof string !== "string") {
|
|
7
|
+
throw new TypeError(
|
|
8
|
+
`Expected \`input\` to be a \`string\`, got \`${typeof string}\``
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
if (typeof count !== "number") {
|
|
12
|
+
throw new TypeError(
|
|
13
|
+
`Expected \`count\` to be a \`number\`, got \`${typeof count}\``
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
if (count < 0) {
|
|
17
|
+
throw new RangeError(
|
|
18
|
+
`Expected \`count\` to be at least 0, got \`${count}\``
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (typeof indent !== "string") {
|
|
22
|
+
throw new TypeError(
|
|
23
|
+
`Expected \`options.indent\` to be a \`string\`, got \`${typeof indent}\``
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
if (count === 0) {
|
|
27
|
+
return string;
|
|
28
|
+
}
|
|
29
|
+
const regex = includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
|
|
30
|
+
return string.replace(regex, indent.repeat(count));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { indentString as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { i as isFullWidth, a as isWide } from './lookup-BE8lEqy4.js';
|
|
2
|
+
|
|
3
|
+
const isFullwidthCodePoint = (codePoint) => {
|
|
4
|
+
if (!Number.isInteger(codePoint)) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return isFullWidth(codePoint) || isWide(codePoint);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { isFullwidthCodePoint as default };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
const ambiguousRanges = [161, 161, 164, 164, 167, 168, 170, 170, 173, 174, 176, 180, 182, 186, 188, 191, 198, 198, 208, 208, 215, 216, 222, 225, 230, 230, 232, 234, 236, 237, 240, 240, 242, 243, 247, 250, 252, 252, 254, 254, 257, 257, 273, 273, 275, 275, 283, 283, 294, 295, 299, 299, 305, 307, 312, 312, 319, 322, 324, 324, 328, 331, 333, 333, 338, 339, 358, 359, 363, 363, 462, 462, 464, 464, 466, 466, 468, 468, 470, 470, 472, 472, 474, 474, 476, 476, 593, 593, 609, 609, 708, 708, 711, 711, 713, 715, 717, 717, 720, 720, 728, 731, 733, 733, 735, 735, 768, 879, 913, 929, 931, 937, 945, 961, 963, 969, 1025, 1025, 1040, 1103, 1105, 1105, 8208, 8208, 8211, 8214, 8216, 8217, 8220, 8221, 8224, 8226, 8228, 8231, 8240, 8240, 8242, 8243, 8245, 8245, 8251, 8251, 8254, 8254, 8308, 8308, 8319, 8319, 8321, 8324, 8364, 8364, 8451, 8451, 8453, 8453, 8457, 8457, 8467, 8467, 8470, 8470, 8481, 8482, 8486, 8486, 8491, 8491, 8531, 8532, 8539, 8542, 8544, 8555, 8560, 8569, 8585, 8585, 8592, 8601, 8632, 8633, 8658, 8658, 8660, 8660, 8679, 8679, 8704, 8704, 8706, 8707, 8711, 8712, 8715, 8715, 8719, 8719, 8721, 8721, 8725, 8725, 8730, 8730, 8733, 8736, 8739, 8739, 8741, 8741, 8743, 8748, 8750, 8750, 8756, 8759, 8764, 8765, 8776, 8776, 8780, 8780, 8786, 8786, 8800, 8801, 8804, 8807, 8810, 8811, 8814, 8815, 8834, 8835, 8838, 8839, 8853, 8853, 8857, 8857, 8869, 8869, 8895, 8895, 8978, 8978, 9312, 9449, 9451, 9547, 9552, 9587, 9600, 9615, 9618, 9621, 9632, 9633, 9635, 9641, 9650, 9651, 9654, 9655, 9660, 9661, 9664, 9665, 9670, 9672, 9675, 9675, 9678, 9681, 9698, 9701, 9711, 9711, 9733, 9734, 9737, 9737, 9742, 9743, 9756, 9756, 9758, 9758, 9792, 9792, 9794, 9794, 9824, 9825, 9827, 9829, 9831, 9834, 9836, 9837, 9839, 9839, 9886, 9887, 9919, 9919, 9926, 9933, 9935, 9939, 9941, 9953, 9955, 9955, 9960, 9961, 9963, 9969, 9972, 9972, 9974, 9977, 9979, 9980, 9982, 9983, 10045, 10045, 10102, 10111, 11094, 11097, 12872, 12879, 57344, 63743, 65024, 65039, 65533, 65533, 127232, 127242, 127248, 127277, 127280, 127337, 127344, 127373, 127375, 127376, 127387, 127404, 917760, 917999, 983040, 1048573, 1048576, 1114109];
|
|
2
|
+
const fullwidthRanges = [12288, 12288, 65281, 65376, 65504, 65510];
|
|
3
|
+
const halfwidthRanges = [8361, 8361, 65377, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65512, 65518];
|
|
4
|
+
const narrowRanges = [32, 126, 162, 163, 165, 166, 172, 172, 175, 175, 10214, 10221, 10629, 10630];
|
|
5
|
+
const wideRanges = [4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203, 9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871, 9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934, 9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981, 9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067, 10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036, 11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272, 12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686, 12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360, 43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126, 65128, 65131, 94176, 94180, 94192, 94198, 94208, 101589, 101631, 101662, 101760, 101874, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110882, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110951, 110960, 111355, 119552, 119638, 119648, 119670, 126980, 126980, 127183, 127183, 127374, 127374, 127377, 127386, 127488, 127490, 127504, 127547, 127552, 127560, 127568, 127569, 127584, 127589, 127744, 127776, 127789, 127797, 127799, 127868, 127870, 127891, 127904, 127946, 127951, 127955, 127968, 127984, 127988, 127988, 127992, 128062, 128064, 128064, 128066, 128252, 128255, 128317, 128331, 128334, 128336, 128359, 128378, 128378, 128405, 128406, 128420, 128420, 128507, 128591, 128640, 128709, 128716, 128716, 128720, 128722, 128725, 128728, 128732, 128735, 128747, 128748, 128756, 128764, 128992, 129003, 129008, 129008, 129292, 129338, 129340, 129349, 129351, 129535, 129648, 129660, 129664, 129674, 129678, 129734, 129736, 129736, 129741, 129756, 129759, 129770, 129775, 129784, 131072, 196605, 196608, 262141];
|
|
6
|
+
|
|
7
|
+
const isInRange = (ranges, codePoint) => {
|
|
8
|
+
let low = 0;
|
|
9
|
+
let high = Math.floor(ranges.length / 2) - 1;
|
|
10
|
+
while (low <= high) {
|
|
11
|
+
const mid = Math.floor((low + high) / 2);
|
|
12
|
+
const i = mid * 2;
|
|
13
|
+
if (codePoint < ranges[i]) {
|
|
14
|
+
high = mid - 1;
|
|
15
|
+
} else if (codePoint > ranges[i + 1]) {
|
|
16
|
+
low = mid + 1;
|
|
17
|
+
} else {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const minimumAmbiguousCodePoint = ambiguousRanges[0];
|
|
25
|
+
const maximumAmbiguousCodePoint = ambiguousRanges.at(-1);
|
|
26
|
+
const minimumFullWidthCodePoint = fullwidthRanges[0];
|
|
27
|
+
const maximumFullWidthCodePoint = fullwidthRanges.at(-1);
|
|
28
|
+
const minimumHalfWidthCodePoint = halfwidthRanges[0];
|
|
29
|
+
const maximumHalfWidthCodePoint = halfwidthRanges.at(-1);
|
|
30
|
+
const minimumNarrowCodePoint = narrowRanges[0];
|
|
31
|
+
const maximumNarrowCodePoint = narrowRanges.at(-1);
|
|
32
|
+
const minimumWideCodePoint = wideRanges[0];
|
|
33
|
+
const maximumWideCodePoint = wideRanges.at(-1);
|
|
34
|
+
const commonCjkCodePoint = 19968;
|
|
35
|
+
const [wideFastPathStart, wideFastPathEnd] = findWideFastPathRange(wideRanges);
|
|
36
|
+
function findWideFastPathRange(ranges) {
|
|
37
|
+
let fastPathStart = ranges[0];
|
|
38
|
+
let fastPathEnd = ranges[1];
|
|
39
|
+
for (let index = 0; index < ranges.length; index += 2) {
|
|
40
|
+
const start = ranges[index];
|
|
41
|
+
const end = ranges[index + 1];
|
|
42
|
+
if (commonCjkCodePoint >= start && commonCjkCodePoint <= end) {
|
|
43
|
+
return [start, end];
|
|
44
|
+
}
|
|
45
|
+
if (end - start > fastPathEnd - fastPathStart) {
|
|
46
|
+
fastPathStart = start;
|
|
47
|
+
fastPathEnd = end;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return [fastPathStart, fastPathEnd];
|
|
51
|
+
}
|
|
52
|
+
const isAmbiguous = (codePoint) => {
|
|
53
|
+
if (codePoint < minimumAmbiguousCodePoint || codePoint > maximumAmbiguousCodePoint) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return isInRange(ambiguousRanges, codePoint);
|
|
57
|
+
};
|
|
58
|
+
const isFullWidth = (codePoint) => {
|
|
59
|
+
if (codePoint < minimumFullWidthCodePoint || codePoint > maximumFullWidthCodePoint) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return isInRange(fullwidthRanges, codePoint);
|
|
63
|
+
};
|
|
64
|
+
const isHalfWidth = (codePoint) => {
|
|
65
|
+
if (codePoint < minimumHalfWidthCodePoint || codePoint > maximumHalfWidthCodePoint) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return isInRange(halfwidthRanges, codePoint);
|
|
69
|
+
};
|
|
70
|
+
const isNarrow = (codePoint) => {
|
|
71
|
+
if (codePoint < minimumNarrowCodePoint || codePoint > maximumNarrowCodePoint) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return isInRange(narrowRanges, codePoint);
|
|
75
|
+
};
|
|
76
|
+
const isWide = (codePoint) => {
|
|
77
|
+
if (codePoint >= wideFastPathStart && codePoint <= wideFastPathEnd) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (codePoint < minimumWideCodePoint || codePoint > maximumWideCodePoint) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return isInRange(wideRanges, codePoint);
|
|
84
|
+
};
|
|
85
|
+
function getCategory(codePoint) {
|
|
86
|
+
if (isAmbiguous(codePoint)) {
|
|
87
|
+
return "ambiguous";
|
|
88
|
+
}
|
|
89
|
+
if (isFullWidth(codePoint)) {
|
|
90
|
+
return "fullwidth";
|
|
91
|
+
}
|
|
92
|
+
if (isHalfWidth(codePoint)) {
|
|
93
|
+
return "halfwidth";
|
|
94
|
+
}
|
|
95
|
+
if (isNarrow(codePoint)) {
|
|
96
|
+
return "narrow";
|
|
97
|
+
}
|
|
98
|
+
if (isWide(codePoint)) {
|
|
99
|
+
return "wide";
|
|
100
|
+
}
|
|
101
|
+
return "neutral";
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { isWide as a, isAmbiguous as b, getCategory as g, isFullWidth as i };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
const RE_GERMAN_DOUBLE_S = /(?<![a-zß])SS(?![a-z])/g;
|
|
1
2
|
const normalizeGermanEszett = (value) => (
|
|
2
3
|
// Replace "SS" with "ß" only when both letters are uppercase
|
|
3
4
|
// This uses a positive lookbehind to ensure we don't convert "ss" or "Ss"
|
|
4
|
-
value.replaceAll(
|
|
5
|
+
value.replaceAll(RE_GERMAN_DOUBLE_S, "ß")
|
|
5
6
|
);
|
|
6
7
|
|
|
7
8
|
export { normalizeGermanEszett as n };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const RE_REPLACEMENT_REGEX = /\$([\d&$`'])/g;
|
|
2
|
+
const RE_REPLACEMENT_STRING = /\$(\d+|&|\$)/g;
|
|
1
3
|
const mergeIntervals = (intervals) => {
|
|
2
4
|
if (intervals.length === 0) {
|
|
3
5
|
return [];
|
|
@@ -23,9 +25,6 @@ const replaceString = (source, searches, ignoreRanges) => {
|
|
|
23
25
|
const potentialMatches = [];
|
|
24
26
|
let matchIdCounter = 0;
|
|
25
27
|
for (const item of searches) {
|
|
26
|
-
if (!item || item.length < 2) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
28
|
const [searchKey, replacementValue] = item;
|
|
30
29
|
if (replacementValue === void 0) {
|
|
31
30
|
continue;
|
|
@@ -41,7 +40,7 @@ const replaceString = (source, searches, ignoreRanges) => {
|
|
|
41
40
|
searchPattern.lastIndex += 1;
|
|
42
41
|
}
|
|
43
42
|
const end = start + original.length - 1;
|
|
44
|
-
const finalReplacement = replacementValue.replaceAll(
|
|
43
|
+
const finalReplacement = replacementValue.replaceAll(RE_REPLACEMENT_REGEX, (substringFound, capturedSymbolOrDigits) => {
|
|
45
44
|
if (capturedSymbolOrDigits === "&") {
|
|
46
45
|
return original;
|
|
47
46
|
}
|
|
@@ -71,7 +70,7 @@ const replaceString = (source, searches, ignoreRanges) => {
|
|
|
71
70
|
const original = searchKey;
|
|
72
71
|
const end = start + original.length - 1;
|
|
73
72
|
const mockMatch = Object.assign([original], { index: start, input: source });
|
|
74
|
-
const finalReplacement = replacementValue.replaceAll(
|
|
73
|
+
const finalReplacement = replacementValue.replaceAll(RE_REPLACEMENT_STRING, (substringFound, capturedSymbolOrDigits) => {
|
|
75
74
|
if (capturedSymbolOrDigits === "&") {
|
|
76
75
|
return original;
|
|
77
76
|
}
|
|
@@ -79,7 +78,7 @@ const replaceString = (source, searches, ignoreRanges) => {
|
|
|
79
78
|
return "$";
|
|
80
79
|
}
|
|
81
80
|
const groupIndex = Number.parseInt(capturedSymbolOrDigits, 10);
|
|
82
|
-
if (
|
|
81
|
+
if (groupIndex > 0 && groupIndex < mockMatch.length) {
|
|
83
82
|
return mockMatch[groupIndex] ?? "";
|
|
84
83
|
}
|
|
85
84
|
return substringFound;
|
|
@@ -112,7 +111,8 @@ const replaceString = (source, searches, ignoreRanges) => {
|
|
|
112
111
|
matchReplacement: void 0
|
|
113
112
|
};
|
|
114
113
|
});
|
|
115
|
-
for (const
|
|
114
|
+
for (const mergedIgnore of mergedIgnores) {
|
|
115
|
+
const range = mergedIgnore;
|
|
116
116
|
for (let index = range[0]; index <= range[1]; index++) {
|
|
117
117
|
if (processedChars[index]) {
|
|
118
118
|
processedChars[index].isIgnored = true;
|
|
@@ -120,7 +120,8 @@ const replaceString = (source, searches, ignoreRanges) => {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
let insertionAfterEnd = "";
|
|
123
|
-
for (const
|
|
123
|
+
for (const potentialMatch of potentialMatches) {
|
|
124
|
+
const match = potentialMatch;
|
|
124
125
|
if (match.original.length === 0 && match.start >= 0 && match.start <= processedChars.length) {
|
|
125
126
|
const targetIndex = match.start;
|
|
126
127
|
if (processedChars[targetIndex]) {
|
|
@@ -133,7 +134,8 @@ const replaceString = (source, searches, ignoreRanges) => {
|
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
|
-
for (const
|
|
137
|
+
for (const potentialMatch of potentialMatches) {
|
|
138
|
+
const match = potentialMatch;
|
|
137
139
|
if (match.original.length === 0) {
|
|
138
140
|
continue;
|
|
139
141
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function stripIndent(string) {
|
|
2
|
+
const match = string.match(/^[ \t]*(?=\S)/gm);
|
|
3
|
+
if (!match) {
|
|
4
|
+
return string;
|
|
5
|
+
}
|
|
6
|
+
let minIndent = Number.POSITIVE_INFINITY;
|
|
7
|
+
for (const indent of match) {
|
|
8
|
+
minIndent = Math.min(minIndent, indent.length);
|
|
9
|
+
}
|
|
10
|
+
if (minIndent === 0 || minIndent === Number.POSITIVE_INFINITY) {
|
|
11
|
+
return string;
|
|
12
|
+
}
|
|
13
|
+
return string.replace(new RegExp(`^[ \\t]{${minIndent}}`, "gm"), "");
|
|
14
|
+
}
|
|
15
|
+
function dedent(string) {
|
|
16
|
+
const trimmed = string.replace(/^(?:[ \t]*\r?\n)+|(?:\r?\n[ \t]*)+$/g, "");
|
|
17
|
+
return stripIndent(trimmed);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { dedent, stripIndent as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import replaceString from './replaceString-
|
|
1
|
+
import { H as RE_THAI } from './constants-BsZS5f0z.js';
|
|
2
|
+
import replaceString from './replaceString-Ce8X2ZQ-.js';
|
|
3
3
|
import { findStringOccurrences, hasPunctuationOrSpace, hasChinese } from '../utilities.js';
|
|
4
4
|
|
|
5
5
|
const UNICODE_BLOCK_0000_00FF = [
|
|
@@ -47618,8 +47618,9 @@ const formatReplaceOption = (option) => {
|
|
|
47618
47618
|
return structuredClone(option);
|
|
47619
47619
|
}
|
|
47620
47620
|
const replaceArray = [];
|
|
47621
|
-
|
|
47622
|
-
|
|
47621
|
+
const keys = Object.keys(option);
|
|
47622
|
+
for (const key of keys) {
|
|
47623
|
+
if (Object.hasOwn(option, key)) {
|
|
47623
47624
|
const value = option[key];
|
|
47624
47625
|
if (typeof value === "string") {
|
|
47625
47626
|
replaceArray.push([key, value]);
|
|
@@ -47630,7 +47631,8 @@ const formatReplaceOption = (option) => {
|
|
|
47630
47631
|
};
|
|
47631
47632
|
const applyThaiRomanization = (input) => {
|
|
47632
47633
|
let output = input;
|
|
47633
|
-
for (
|
|
47634
|
+
for (let entryIndex = 0; entryIndex < THAI_REPLACEMENT.length; entryIndex += 1) {
|
|
47635
|
+
const entry = THAI_REPLACEMENT[entryIndex];
|
|
47634
47636
|
const [search, replace, type] = entry;
|
|
47635
47637
|
if (typeof search !== "string" || typeof replace !== "string") {
|
|
47636
47638
|
continue;
|
|
@@ -47713,7 +47715,7 @@ const transliterate = (source, options) => {
|
|
|
47713
47715
|
s = opt.unknown;
|
|
47714
47716
|
} else {
|
|
47715
47717
|
const codePointString = String(currentActualCodePoint);
|
|
47716
|
-
const found = Object.
|
|
47718
|
+
const found = Object.hasOwn(currentCharmap, codePointString);
|
|
47717
47719
|
if (found) {
|
|
47718
47720
|
s = currentCharmap[codePointString];
|
|
47719
47721
|
} else if (isCurrentCharChinese) {
|
|
@@ -47722,9 +47724,7 @@ const transliterate = (source, options) => {
|
|
|
47722
47724
|
s = opt.unknown;
|
|
47723
47725
|
}
|
|
47724
47726
|
}
|
|
47725
|
-
|
|
47726
|
-
s = opt.unknown;
|
|
47727
|
-
}
|
|
47727
|
+
s ??= opt.unknown;
|
|
47728
47728
|
}
|
|
47729
47729
|
const determinedCharWasChinese = !isIgnored && isCurrentCharChinese;
|
|
47730
47730
|
if (opt.fixChineseSpacing && !isIgnored) {
|
|
@@ -47736,7 +47736,7 @@ const transliterate = (source, options) => {
|
|
|
47736
47736
|
} else {
|
|
47737
47737
|
lastCharWasChinese = false;
|
|
47738
47738
|
}
|
|
47739
|
-
result += s
|
|
47739
|
+
result += s;
|
|
47740
47740
|
index += charLength;
|
|
47741
47741
|
}
|
|
47742
47742
|
input = result;
|