@visulima/string 3.0.0-alpha.9 → 3.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.
Files changed (128) hide show
  1. package/CHANGELOG.md +305 -0
  2. package/LICENSE.md +68 -3
  3. package/README.md +80 -2
  4. package/dist/align-text.d.ts +35 -0
  5. package/dist/align-text.js +2 -34
  6. package/dist/case/camel-case.d.ts +17 -3
  7. package/dist/case/camel-case.js +1 -55
  8. package/dist/case/capital-case.d.ts +14 -3
  9. package/dist/case/capital-case.js +1 -47
  10. package/dist/case/constant-case.d.ts +14 -3
  11. package/dist/case/constant-case.js +1 -7
  12. package/dist/case/dot-case.d.ts +14 -3
  13. package/dist/case/dot-case.js +1 -7
  14. package/dist/case/flat-case.d.ts +12 -3
  15. package/dist/case/flat-case.js +1 -7
  16. package/dist/case/flip-case.d.ts +16 -3
  17. package/dist/case/flip-case.js +1 -82
  18. package/dist/case/identify-case.d.ts +15 -3
  19. package/dist/case/identify-case.js +1 -66
  20. package/dist/case/index.d.ts +8 -3
  21. package/dist/case/index.js +1 -20
  22. package/dist/case/kebab-case.d.ts +25 -3
  23. package/dist/case/kebab-case.js +1 -55
  24. package/dist/case/lower-first.d.ts +13 -3
  25. package/dist/case/lower-first.js +1 -9
  26. package/dist/case/no-case.d.ts +14 -3
  27. package/dist/case/no-case.js +1 -7
  28. package/dist/case/pascal-case.d.ts +17 -3
  29. package/dist/case/pascal-case.js +1 -48
  30. package/dist/case/pascal-snake-case.d.ts +14 -3
  31. package/dist/case/pascal-snake-case.js +1 -28
  32. package/dist/case/path-case.d.ts +14 -3
  33. package/dist/case/path-case.js +1 -7
  34. package/dist/case/sentence-case.d.ts +14 -3
  35. package/dist/case/sentence-case.js +1 -54
  36. package/dist/case/snake-case.d.ts +14 -3
  37. package/dist/case/snake-case.js +1 -7
  38. package/dist/case/split-by-case.d.ts +29 -3
  39. package/dist/case/split-by-case.js +1 -763
  40. package/dist/case/title-case.d.ts +12 -3
  41. package/dist/case/title-case.js +1 -40
  42. package/dist/case/train-case.d.ts +14 -3
  43. package/dist/case/train-case.js +1 -40
  44. package/dist/case/upper-first.d.ts +13 -3
  45. package/dist/case/upper-first.js +1 -9
  46. package/dist/closest-string.d.ts +32 -0
  47. package/dist/closest-string.js +1 -22
  48. package/dist/compare-similarity.d.ts +37 -0
  49. package/dist/compare-similarity.js +1 -12
  50. package/dist/count-occurrences.d.ts +9 -0
  51. package/dist/count-occurrences.js +1 -0
  52. package/dist/direction.d.ts +7 -0
  53. package/dist/direction.js +1 -0
  54. package/dist/east-asian-width.d.ts +58 -0
  55. package/dist/east-asian-width.js +1 -0
  56. package/dist/excerpt.d.ts +25 -0
  57. package/dist/excerpt.js +53 -0
  58. package/dist/get-string-truncated-width.d.ts +151 -0
  59. package/dist/get-string-truncated-width.js +1 -332
  60. package/dist/get-string-width.d.ts +58 -0
  61. package/dist/get-string-width.js +1 -5
  62. package/dist/indent.d.ts +88 -0
  63. package/dist/indent.js +1 -0
  64. package/dist/index.d.ts +12 -20
  65. package/dist/index.js +1 -44
  66. package/dist/is-fullwidth-code-point.d.ts +7 -0
  67. package/dist/is-fullwidth-code-point.js +1 -0
  68. package/dist/levenshtein.d.ts +25 -0
  69. package/dist/levenshtein.js +1 -0
  70. package/dist/native-string-types.d.ts +241 -18
  71. package/dist/outdent.d.ts +74 -0
  72. package/dist/outdent.js +1 -109
  73. package/dist/packem_shared/_isFullWidth-Dqc3MWgl.js +1 -0
  74. package/dist/packem_shared/closest-C6YDQs4m.js +1 -0
  75. package/dist/packem_shared/constants-aPzGW29R.js +1 -0
  76. package/dist/packem_shared/dedent-CPjAYUXh.js +1 -0
  77. package/dist/packem_shared/eastAsianWidth-DJV8Kqd-.js +1 -0
  78. package/dist/packem_shared/generate-cache-key-B_0X7MKm.js +1 -0
  79. package/dist/packem_shared/indent-cz8WMI0e.js +1 -0
  80. package/dist/packem_shared/joinSegments-CaHT-45s.js +1 -0
  81. package/dist/packem_shared/lru-cache-BtMSrYQJ.js +1 -0
  82. package/dist/packem_shared/normalize-german-eszett-hNMwtGjd.js +1 -0
  83. package/dist/packem_shared/redent-ByOoJ6fN.js +1 -0
  84. package/dist/packem_shared/strip-vt-control-characters-BW1RglLp.js +1 -0
  85. package/dist/packem_shared/types.d-CMNqA5bi.d.ts +402 -0
  86. package/dist/packem_shared/types.d-LgsTR37y.d.ts +360 -0
  87. package/dist/replace-string.d.ts +10 -0
  88. package/dist/replace-string.js +1 -0
  89. package/dist/slice.d.ts +42 -0
  90. package/dist/slice.js +1 -415
  91. package/dist/slugify.d.ts +10 -1
  92. package/dist/slugify.js +1 -46
  93. package/dist/test/utils.d.ts +17 -0
  94. package/dist/test/utils.js +13 -88
  95. package/dist/test/vitest.d.ts +3 -0
  96. package/dist/test/vitest.js +1 -5
  97. package/dist/transliterate.d.ts +10 -0
  98. package/dist/transliterate.js +5 -0
  99. package/dist/truncate.d.ts +43 -0
  100. package/dist/truncate.js +1 -112
  101. package/dist/utilities.d.ts +28 -2
  102. package/dist/utilities.js +1 -52
  103. package/dist/word-similarity-sort.d.ts +34 -0
  104. package/dist/word-similarity-sort.js +1 -22
  105. package/dist/word-wrap.d.ts +44 -0
  106. package/dist/word-wrap.js +8 -639
  107. package/package.json +70 -36
  108. package/dist/packem_shared/LRUCache-3r3SovvR.js +0 -46
  109. package/dist/packem_shared/closest-IHuSvnSn.js +0 -139
  110. package/dist/packem_shared/closestN-DUsjgiXb.js +0 -25
  111. package/dist/packem_shared/constants-BsZS5f0z.js +0 -95
  112. package/dist/packem_shared/countOccurrences-CS9XprQN.js +0 -22
  113. package/dist/packem_shared/direction-C9gfWWTK.js +0 -16
  114. package/dist/packem_shared/eastAsianWidthType-SD3YniiT.js +0 -20
  115. package/dist/packem_shared/excerpt-COsVNttN.js +0 -1502
  116. package/dist/packem_shared/generate-cache-key-DdayDfjV.js +0 -6
  117. package/dist/packem_shared/indent-D3DSCa6s.js +0 -33
  118. package/dist/packem_shared/isFullwidthCodePoint-IFXZxNjq.js +0 -10
  119. package/dist/packem_shared/joinSegments-CvxSgKz0.js +0 -44
  120. package/dist/packem_shared/lookup-BE8lEqy4.js +0 -104
  121. package/dist/packem_shared/lru-cache.d-BsP6kbVJ.d.ts +0 -13
  122. package/dist/packem_shared/normalize-german-eszett-4p3yKEzn.js +0 -8
  123. package/dist/packem_shared/redent-DSb1IJWn.js +0 -8
  124. package/dist/packem_shared/replaceString-Ce8X2ZQ-.js +0 -192
  125. package/dist/packem_shared/stripIndent-D_TRjxZ_.js +0 -20
  126. package/dist/packem_shared/transliterate-CKt9VK7D.js +0 -47756
  127. package/dist/packem_shared/types.d-BVNv675q.d.ts +0 -61
  128. package/dist/packem_shared/types.d-DfgbcNKh.d.ts +0 -57
@@ -1,38 +1,277 @@
1
+
2
+ /**
3
+ * Creates a tuple type of specified length filled with a given type.
4
+ * @template L - The desired length of the tuple
5
+ * @template T - The type to fill the tuple with (defaults to unknown)
6
+ * @template Result - Internal accumulator for recursive type building
7
+ * @returns A tuple type of length L filled with type T
8
+ */
1
9
  type TupleOf<L extends number, T = unknown, Result extends any[] = []> = Result["length"] extends L ? Result : TupleOf<L, T, [...Result, T]>;
10
+ /**
11
+ * Internal type for implementing string slicing with both start and end indices.
12
+ * Handles edge cases and type safety for string literal types.
13
+ * @template T - The input string type
14
+ * @template StartIndex - The starting index for the slice
15
+ * @template EndIndex - The ending index for the slice
16
+ * @template Result - Internal accumulator for building the result string
17
+ */
2
18
  type InternalSliceType<T extends string, StartIndex extends number, EndIndex extends number, Result extends string = ""> = IsNumberLiteral<EndIndex | StartIndex> extends true ? T extends `${infer Head}${infer Rest}` ? IsStringLiteral<Head> extends true ? StartIndex extends 0 ? EndIndex extends 0 ? Result : InternalSliceType<Rest, 0, Math.Subtract<Math.GetPositiveIndex<T, EndIndex>, 1>, `${Result}${Head}`> : InternalSliceType<Rest, Math.Subtract<Math.GetPositiveIndex<T, StartIndex>, 1>, Math.Subtract<Math.GetPositiveIndex<T, EndIndex>, 1>, Result> : EndIndex | StartIndex extends 0 ? Result : string : IsStringLiteral<T> extends true ? Result : EndIndex | StartIndex extends 0 ? Result : string : string;
19
+ /**
20
+ * Internal type for implementing string slicing with only a start index.
21
+ * Provides type-safe string slicing functionality for string literal types.
22
+ * @template T - The input string type
23
+ * @template StartIndex - The starting index for the slice
24
+ * @template Result - Internal accumulator for building the result string
25
+ */
3
26
  type SliceStartType<T extends string, StartIndex extends number, Result extends string = ""> = IsNumberLiteral<StartIndex> extends true ? T extends `${infer Head}${infer Rest}` ? IsStringLiteral<Head> extends true ? StartIndex extends 0 ? T : SliceStartType<Rest, Math.Subtract<Math.GetPositiveIndex<T, StartIndex>, 1>, Result> : string : IsStringLiteral<T> extends true ? Result : StartIndex extends 0 ? Result : string : string;
4
27
  type InternalEndsWithType<T extends string, S extends string, P extends number> = All<[IsStringLiteral<S>, IsNumberLiteral<P>]> extends true ? Math.IsNegative<P> extends false ? P extends Length<T> ? IsStringLiteral<T> extends true ? S extends Slice<T, Math.Subtract<Length<T>, Length<S>>, Length<T>> ? true : false : EndsWithNoPositionType<Slice<T, 0, P>, S> : EndsWithNoPositionType<Slice<T, 0, P>, S> : false : boolean;
28
+ /**
29
+ * Internal type for implementing EndsWith functionality without a position parameter.
30
+ * Uses string reversal to check if a string ends with another string.
31
+ * @template T - The string to check
32
+ * @template S - The suffix to check for
33
+ */
5
34
  type EndsWithNoPositionType<T extends string, S extends string> = StartsWith<Reverse<T>, Reverse<S>>;
35
+ /**
36
+ * Namespace containing type-level mathematical operations.
37
+ * These utilities provide type-safe arithmetic and number manipulation.
38
+ */
6
39
  declare namespace Math {
7
40
  type Subtract<A extends number, B extends number> = number extends A | B ? number : TupleOf<A> extends [...infer U, ...TupleOf<B>] ? U["length"] : 0;
8
41
  type IsNegative<T extends number> = number extends T ? boolean : `${T}` extends `-${number}` ? true : false;
9
42
  type Abs<T extends number> = `${T}` extends `-${infer U extends number}` ? U : T;
10
43
  type GetPositiveIndex<T extends string, I extends number> = IsNegative<I> extends false ? I : Subtract<Length<T>, Abs<I>>;
11
44
  }
45
+ /**
46
+ * Type predicate that determines if a number type is a literal type rather than the general 'number' type.
47
+ * For example: IsNumberLiteral&lt;42> is true, but IsNumberLiteral&lt;number> is false.
48
+ * @template T - The number type to check
49
+ * @returns true if T is a number literal type, false otherwise
50
+ */
12
51
  type IsNumberLiteral<T extends number> = [T] extends [number] ? ([number] extends [T] ? false : true) : false;
13
52
  type IsBooleanLiteral<T extends boolean> = [T] extends [boolean] ? ([boolean] extends [T] ? false : true) : false;
53
+ /**
54
+ * Type-level string reversal utility.
55
+ * Recursively builds the reversed string using template literal types.
56
+ * @template T - The string type to reverse
57
+ * @template Accumulator - Internal accumulator for building the reversed string
58
+ * @returns A type representing the reversed string
59
+ * @example
60
+ * type ReversedHello = Reverse<'hello'> // type ReversedHello = 'olleh'
61
+ */
14
62
  type Reverse<T extends string, Accumulator extends string = ""> = T extends `${infer Head}${infer Tail}` ? Reverse<Tail, `${Head}${Accumulator}`> : Accumulator extends "" ? T : `${T}${Accumulator}`;
63
+ /**
64
+ * Type predicate that checks if all elements in a boolean array type are the literal 'true'.
65
+ * Distinguishes between literal true/false and the general boolean type.
66
+ * @template T - Array of boolean types to check
67
+ * @returns true if all elements are the literal true, false otherwise
68
+ * @example
69
+ * type AllTrue = All<[true, true]> // type AllTrue = true
70
+ * type NotAllTrue = All<[true, false]> // type NotAllTrue = false
71
+ */
15
72
  type All<BoolArray extends boolean[]> = IsBooleanLiteral<BoolArray[number]> extends true ? BoolArray extends [infer Head extends boolean, ...infer Rest extends boolean[]] ? Head extends true ? All<Rest> : false : true : false;
73
+ /**
74
+ * Type predicate that determines if a string type is a literal type rather than the general 'string' type.
75
+ * @template T - The string type to check
76
+ * @returns true if T is a string literal type, false if it's the general string type
77
+ * @example
78
+ * type IsLiteral = IsStringLiteral<'hello'> // type IsLiteral = true
79
+ * type NotLiteral = IsStringLiteral<string> // type NotLiteral = false
80
+ */
16
81
  type IsStringLiteral<T extends string> = [T] extends [string] ? [string] extends [T] ? false : Uppercase<T> extends Uppercase<Lowercase<T>> ? Lowercase<T> extends Lowercase<Uppercase<T>> ? true : false : false : false;
17
82
  type IsStringLiteralArray<StringArray extends ReadonlyArray<string>> = IsStringLiteral<StringArray[number]> extends true ? true : false;
83
+ /**
84
+ * Type-safe utility to get the character at a specific index in a string literal type.
85
+ * @template T - The string type to extract a character from
86
+ * @template Index - The numeric index of the desired character
87
+ * @returns The character type at the specified index, or never if the index is invalid
88
+ * @example
89
+ * type FirstChar = CharAt<'hello', 0> // type FirstChar = 'h'
90
+ */
18
91
  type CharAt<T extends string, Index extends number> = All<[IsStringLiteral<T>, IsNumberLiteral<Index>]> extends true ? Split<T>[Index] : string;
92
+ /**
93
+ * Type-level string concatenation for tuples of string literals.
94
+ * Joins all strings in the tuple into a single string type.
95
+ * @template T - Tuple of string types to concatenate
96
+ * @returns A single string type representing the concatenated result
97
+ * @example
98
+ * type Combined = Concat<['hello', ' ', 'world']> // type Combined = 'hello world'
99
+ */
19
100
  type Concat<T extends string[]> = Join<T>;
101
+ /**
102
+ * Type-level implementation of string.endsWith() functionality.
103
+ * Checks if a string type ends with another string type at a given position.
104
+ * @template T - The string type to check
105
+ * @template S - The suffix to check for
106
+ * @template P - Optional position at which to end the search
107
+ * @returns A boolean type indicating if T ends with S at position P
108
+ * @example
109
+ * type EndsWithWorld = EndsWith<'hello world', 'world'> // type EndsWithWorld = true
110
+ * type DoesNotEnd = EndsWith<'hello world', 'hello'> // type DoesNotEnd = false
111
+ */
20
112
  type EndsWith<T extends string, S extends string, P extends number | undefined = undefined> = P extends number ? InternalEndsWithType<T, S, P> : EndsWithNoPositionType<T, S>;
113
+ /**
114
+ * Type-level implementation of string.includes() functionality.
115
+ * Determines if one string type contains another string type starting at an optional position.
116
+ * @template T - The string type to search within
117
+ * @template S - The string type to search for
118
+ * @template P - Optional position to start the search from
119
+ * @returns A boolean type indicating if S is found within T starting at P
120
+ * @example
121
+ * type HasWorld = Includes<'hello world', 'world'> // type HasWorld = true
122
+ * type NoWorld = Includes<'hello', 'world'> // type NoWorld = false
123
+ */
21
124
  type Includes<T extends string, S extends string, P extends number = 0> = string extends S | T ? boolean : Math.IsNegative<P> extends false ? P extends 0 ? T extends `${string}${S}${string}` ? true : false : Includes<Slice<T, P>, S> : Includes<T, S>;
125
+ /**
126
+ * Type-level implementation of Array.join() functionality for string tuples.
127
+ * Combines string literal types in a tuple using a delimiter.
128
+ * @template T - Tuple of string types to join
129
+ * @template Delimiter - The delimiter to insert between elements
130
+ * @returns A string type representing the joined result
131
+ * @example
132
+ * type Joined = Join<['a', 'b', 'c'], '.'> // type Joined = 'a.b.c'
133
+ */
22
134
  type Join<T extends ReadonlyArray<string>, Delimiter extends string = ""> = All<[IsStringLiteralArray<T>, IsStringLiteral<Delimiter>]> extends true ? T extends readonly [infer First extends string, ...infer Rest extends string[]] ? Rest extends [] ? First : `${First}${Delimiter}${Join<Rest, Delimiter>}` : "" : string;
135
+ /**
136
+ * Type-level utility to compute the length of a string literal type.
137
+ * @template T - The string type to measure
138
+ * @returns A number literal type representing the string's length
139
+ * @example
140
+ * type Len = Length<'hello'> // type Len = 5
141
+ */
23
142
  type Length<T extends string> = IsStringLiteral<T> extends true ? Split<T>["length"] : number;
24
- type PadEnd<T extends string, Times extends number = 0, Pad extends string = " "> = All<[IsStringLiteral<Pad | T>, IsNumberLiteral<Times>]> extends true ? Math.IsNegative<Times> extends false ? Math.Subtract<Times, Length<T>> extends infer Missing extends number ? `${T}${Slice<Repeat<Pad, Missing>, 0, Missing>}` : never : T : string;
25
- type PadStart<T extends string, Times extends number = 0, Pad extends string = " "> = All<[IsStringLiteral<Pad | T>, IsNumberLiteral<Times>]> extends true ? Math.IsNegative<Times> extends false ? Math.Subtract<Times, Length<T>> extends infer Missing extends number ? `${Slice<Repeat<Pad, Missing>, 0, Missing>}${T}` : never : T : string;
143
+ /**
144
+ * Type-level implementation of string.padEnd() functionality.
145
+ * Adds padding to the end of a string type until it reaches a specified length.
146
+ * @template T - The string type to pad
147
+ * @template Times - Target total length of the padded string
148
+ * @template Pad - The string to use as padding (defaults to space)
149
+ * @returns A string type with the padding added to the end
150
+ * @example
151
+ * type Padded = PadEnd<'hello', 7, '_'> // type Padded = 'hello__'
152
+ */
153
+ type PadEnd<T extends string, Times extends number = 0, Pad extends string = " "> = All<[IsStringLiteral<Pad | T>, IsNumberLiteral<Times>]> extends true ? Math.IsNegative<Times> extends false ? Math.Subtract<Times, Length<T>> extends (infer Missing extends number) ? `${T}${Slice<Repeat<Pad, Missing>, 0, Missing>}` : never : T : string;
154
+ /**
155
+ * Type-level implementation of string.padStart() functionality.
156
+ * Adds padding to the beginning of a string type until it reaches a specified length.
157
+ * @template T - The string type to pad
158
+ * @template Times - Target total length of the padded string
159
+ * @template Pad - The string to use as padding (defaults to space)
160
+ * @returns A string type with the padding added to the start
161
+ * @example
162
+ * type Padded = PadStart<'hello', 7, '_'> // type Padded = '__hello'
163
+ */
164
+ type PadStart<T extends string, Times extends number = 0, Pad extends string = " "> = All<[IsStringLiteral<Pad | T>, IsNumberLiteral<Times>]> extends true ? Math.IsNegative<Times> extends false ? Math.Subtract<Times, Length<T>> extends (infer Missing extends number) ? `${Slice<Repeat<Pad, Missing>, 0, Missing>}${T}` : never : T : string;
165
+ /**
166
+ * Type-level implementation of string.repeat() functionality.
167
+ * Creates a new string type by repeating the input string a specified number of times.
168
+ * @template T - The string type to repeat
169
+ * @template Times - The number of times to repeat the string
170
+ * @returns A string type containing T repeated Times times
171
+ * @example
172
+ * type Repeated = Repeat<'abc', 2> // type Repeated = 'abcabc'
173
+ */
26
174
  type Repeat<T extends string, Times extends number = 0> = All<[IsStringLiteral<T>, IsNumberLiteral<Times>]> extends true ? Times extends 0 ? "" : Math.IsNegative<Times> extends false ? Join<TupleOf<Times, T>> : never : string;
175
+ /**
176
+ * Type-level implementation of string.replaceAll() functionality.
177
+ * Replaces all occurrences of a substring with another string.
178
+ * @template Sentence - The string type to perform replacements on
179
+ * @template Lookup - The string or RegExp pattern to search for. When a RegExp is used, the result type widens to string.
180
+ * @template Replacement - The string type to replace matches with
181
+ * @returns A string type with all occurrences of Lookup replaced with Replacement. When Lookup is a RegExp, returns string.
182
+ * @example
183
+ * type Replaced = ReplaceAll<'hello hello', 'hello', 'hi'> // type Replaced = 'hi hi'
184
+ */
27
185
  type ReplaceAll<Sentence extends string, Lookup extends RegExp | string, Replacement extends string = ""> = Lookup extends string ? IsStringLiteral<Lookup | Replacement | Sentence> extends true ? Sentence extends `${infer Rest}${Lookup}${infer Rest2}` ? `${Rest}${Replacement}${ReplaceAll<Rest2, Lookup, Replacement>}` : Sentence : string : string;
186
+ /**
187
+ * Type-level implementation of string.replace() functionality.
188
+ * Replaces the first occurrence of a substring with another string.
189
+ * @template Sentence - The string type to perform replacement on
190
+ * @template Lookup - The string or RegExp pattern to search for. When a RegExp is used, the result type widens to string.
191
+ * @template Replacement - The string type to replace the match with
192
+ * @returns A string type with the first occurrence of Lookup replaced with Replacement. When Lookup is a RegExp, returns string.
193
+ * @example
194
+ * type Replaced = Replace<'hello hello', 'hello', 'hi'> // type Replaced = 'hi hello'
195
+ */
28
196
  type Replace<Sentence extends string, Lookup extends RegExp | string, Replacement extends string = ""> = Lookup extends string ? IsStringLiteral<Lookup | Replacement | Sentence> extends true ? Sentence extends `${infer Rest}${Lookup}${infer Rest2}` ? `${Rest}${Replacement}${Rest2}` : Sentence : string : string;
197
+ /**
198
+ * Type-level implementation of string.slice() functionality.
199
+ * Extracts a portion of a string type between start and end indices.
200
+ * @template T - The string type to slice
201
+ * @template StartIndex - The starting index of the slice
202
+ * @template EndIndex - The ending index of the slice (optional)
203
+ * @returns A string type containing the characters between the indices
204
+ * @example
205
+ * type Sliced = Slice<'hello world', 0, 5> // type Sliced = 'hello'
206
+ * type ToEnd = Slice<'hello world', 6> // type ToEnd = 'world'
207
+ */
29
208
  type Slice<T extends string, StartIndex extends number = 0, EndIndex extends number | undefined = undefined> = EndIndex extends number ? InternalSliceType<T, StartIndex, EndIndex> : SliceStartType<T, StartIndex>;
209
+ /**
210
+ * Type-level implementation of string.split() functionality.
211
+ * Splits a string type into a tuple of string types based on a delimiter.
212
+ * @template T - The string type to split
213
+ * @template Delimiter - The string type to use as a separator
214
+ * @returns A tuple type containing the split string parts
215
+ * @example
216
+ * type Parts = Split<'a,b,c', ','> // type Parts = ['a', 'b', 'c']
217
+ */
30
218
  type Split<T extends string, Delimiter extends string = ""> = IsStringLiteral<Delimiter | T> extends true ? T extends `${infer First}${Delimiter}${infer Rest}` ? [First, ...Split<Rest, Delimiter>] : T extends "" ? [] : [T] : string[];
219
+ /**
220
+ * Type-level implementation of string.startsWith() functionality.
221
+ * Checks if a string type begins with another string type at a given position.
222
+ * @template T - The string type to check
223
+ * @template S - The prefix to check for
224
+ * @template P - Optional position at which to start the search
225
+ * @returns A boolean type indicating if T starts with S at position P
226
+ * @example
227
+ * type StartsWithHello = StartsWith<'hello world', 'hello'> // type StartsWithHello = true
228
+ * type DoesNotStart = StartsWith<'hello world', 'world'> // type DoesNotStart = false
229
+ */
31
230
  type StartsWith<T extends string, S extends string, P extends number = 0> = All<[IsStringLiteral<S>, IsNumberLiteral<P>]> extends true ? Math.IsNegative<P> extends false ? P extends 0 ? S extends `${infer SHead}${infer SRest}` ? T extends `${infer THead}${infer TRest}` ? IsStringLiteral<SHead | THead> extends true ? THead extends SHead ? StartsWith<TRest, SRest> : false : boolean : IsStringLiteral<T> extends true ? false : boolean : true : StartsWith<Slice<T, P>, S> : StartsWith<T, S> : boolean;
231
+ /**
232
+ * Type-level implementation of string.trimEnd() functionality.
233
+ * Removes whitespace characters from the end of a string type.
234
+ * @template T - The string type to trim
235
+ * @returns A string type with trailing whitespace removed
236
+ * @example
237
+ * type Trimmed = TrimEnd<'hello '> // type Trimmed = 'hello'
238
+ */
32
239
  type TrimEnd<T extends string> = T extends `${infer Rest} ` ? TrimEnd<Rest> : T;
240
+ /**
241
+ * Type-level implementation of string.trimStart() functionality.
242
+ * Removes whitespace characters from the beginning of a string type.
243
+ * @template T - The string type to trim
244
+ * @returns A string type with leading whitespace removed
245
+ * @example
246
+ * type Trimmed = TrimStart<' hello'> // type Trimmed = 'hello'
247
+ */
33
248
  type TrimStart<T extends string> = T extends ` ${infer Rest}` ? TrimStart<Rest> : T;
249
+ /**
250
+ * Type-level implementation of string.trim() functionality.
251
+ * Removes whitespace characters from both ends of a string type.
252
+ * @template T - The string type to trim
253
+ * @returns A string type with both leading and trailing whitespace removed
254
+ * @example
255
+ * type Trimmed = Trim<' hello '> // type Trimmed = 'hello'
256
+ */
34
257
  type Trim<T extends string> = TrimEnd<TrimStart<T>>;
258
+ /**
259
+ * Type-level implementation of string.toLowerCase() functionality.
260
+ * Converts all alphabetic characters in a string type to lowercase.
261
+ * @template T - The string type to convert
262
+ * @returns A string type with all characters converted to lowercase
263
+ * @example
264
+ * type Lower = ToLowerCase<'HELLO'> // type Lower = 'hello'
265
+ */
35
266
  type ToLowerCase<T extends string> = IsStringLiteral<T> extends true ? Lowercase<T> : string;
267
+ /**
268
+ * Type-level implementation of string.toUpperCase() functionality.
269
+ * Converts all alphabetic characters in a string type to uppercase.
270
+ * @template T - The string type to convert
271
+ * @returns A string type with all characters converted to uppercase
272
+ * @example
273
+ * type Upper = ToUpperCase<'hello'> // type Upper = 'HELLO'
274
+ */
36
275
  type ToUpperCase<T extends string> = IsStringLiteral<T> extends true ? Uppercase<T> : string;
37
276
  declare global {
38
277
  interface String {
@@ -41,20 +280,17 @@ declare global {
41
280
  * @param index The zero-based index of the desired character.
42
281
  */
43
282
  charAt<T extends string = string, I extends number = number>(this: T, index: I): CharAt<T, I>;
44
-
45
283
  /**
46
284
  * Returns a string that contains the concatenation of two or more strings.
47
285
  * @param strings The strings to append to the end of the string.
48
286
  */
49
287
  concat<T extends string = string, S extends string[] | string = string>(this: T, ...strings: S extends string ? [S] : S extends string[] ? S : never): S extends string ? Concat<[T, S]> : S extends string[] ? Concat<[T, ...S]> : never;
50
-
51
288
  /**
52
289
  * Returns true if the sequence of elements of searchString converted to a String is the
53
290
  * same as the corresponding elements of this object (converted to a String) starting at
54
291
  * position. Otherwise returns false.
55
292
  */
56
293
  endsWith<T extends string = string, S extends string = string, P extends number | undefined = undefined>(this: T, searchString: S, position?: P): EndsWith<T, S, P>;
57
-
58
294
  /**
59
295
  * Returns true if searchString appears as a substring of the result of converting this
60
296
  * object to a String, at one or more positions that are greater than or equal to
@@ -63,12 +299,10 @@ declare global {
63
299
  * @param position If position is undefined, 0 is assumed, so as to search all of the String.
64
300
  */
65
301
  includes<T extends string = string, S extends string = string, P extends number = 0>(this: T, searchString: S, position?: P): Includes<T, S, P>;
66
-
67
302
  /**
68
303
  * Returns the length of a String object.
69
304
  */
70
305
  length: Length<this>;
71
-
72
306
  /**
73
307
  * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
74
308
  * The padding is applied from the end (right) of the current string.
@@ -76,7 +310,6 @@ declare global {
76
310
  * @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied.
77
311
  */
78
312
  padEnd<T extends string = string, N extends number = number, P extends string = " ">(this: T, maxLength: N, fillString?: P): PadEnd<T, N, P>;
79
-
80
313
  /**
81
314
  * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
82
315
  * The padding is applied from the start (left) of the current string.
@@ -84,61 +317,51 @@ declare global {
84
317
  * @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied.
85
318
  */
86
319
  padStart<T extends string = string, N extends number = number, P extends string = " ">(this: T, maxLength: N, fillString?: P): PadStart<T, N, P>;
87
-
88
320
  /**
89
321
  * Replace text in a string, using a regular expression or search string.
90
322
  * @param searchValue A string to search for.
91
323
  * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
92
324
  */
93
325
  replace<T extends string = string, S extends RegExp | string = string, R extends string = string>(this: T, searchValue: S, replaceValue: R): Replace<T, S, R>;
94
-
95
326
  /**
96
327
  * Replace all instances of a substring in a string, using a regular expression or search string.
97
328
  * @param searchValue A string to search for.
98
329
  * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
99
330
  */
100
331
  replaceAll<T extends string = string, S extends RegExp | string = string, R extends string = string>(this: T, searchValue: S, replaceValue: R): ReplaceAll<T, S, R>;
101
-
102
332
  /**
103
333
  * Returns a section of a string.
104
334
  * @param start The index to the beginning of the specified portion of stringObj.
105
335
  * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end.
106
336
  */
107
337
  slice<T extends string = string, S extends number = number, E extends number | undefined = undefined>(this: T, start?: S, end?: E): Slice<T, S, E>;
108
-
109
338
  /**
110
339
  * Split a string into substrings using the specified separator and return them as an array.
111
340
  * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.
112
341
  */
113
342
  split<T extends string = string, S extends string = string>(this: T, separator: S): Split<T, S>;
114
-
115
343
  /**
116
344
  * Returns true if the sequence of elements of searchString converted to a String is the
117
345
  * same as the corresponding elements of this object (converted to a String) starting at
118
346
  * position. Otherwise returns false.
119
347
  */
120
348
  startsWith<T extends string = string, S extends string = string, P extends number = 0>(this: T, searchString: S, position?: P): StartsWith<T, S, P>;
121
-
122
349
  /**
123
350
  * Converts all alphabetic characters in a string to lowercase.
124
351
  */
125
352
  toLowerCase<T extends string = string>(this: T): ToLowerCase<T>;
126
-
127
353
  /**
128
354
  * Converts all alphabetic characters in a string to uppercase.
129
355
  */
130
356
  toUpperCase<T extends string = string>(this: T): ToUpperCase<T>;
131
-
132
357
  /**
133
358
  * Returns a string with all whitespace removed from both ends of a string.
134
359
  */
135
360
  trim<T extends string = string>(this: T): Trim<T>;
136
-
137
361
  /**
138
362
  * Returns a string with all whitespace removed from the end of a string.
139
363
  */
140
364
  trimEnd<T extends string = string>(this: T): TrimEnd<T>;
141
-
142
365
  /**
143
366
  * Returns a string with all whitespace removed from the start of a string.
144
367
  */
package/dist/outdent.d.ts CHANGED
@@ -1,14 +1,88 @@
1
1
  declare const outdent: Outdent;
2
+ /**
3
+ * Represents the outdent function, which can be called as a template tag
4
+ * or as a function to create a new instance with specific options.
5
+ * It also includes a `.string()` method for processing regular strings.
6
+ */
2
7
  interface Outdent {
8
+ /**
9
+ * Remove indentation from a template literal.
10
+ * Tag function for template literals.
11
+ * @param strings The static string parts of the template literal.
12
+ * @param values The interpolated values.
13
+ * @returns The processed string with indentation removed.
14
+ */
3
15
  (strings: TemplateStringsArray, ...values: any[]): string;
16
+ /**
17
+ * Create and return a new Outdent instance with the given options.
18
+ * @param options Configuration options for the new instance.
19
+ * @returns A new Outdent function instance.
20
+ */
4
21
  (options: Options): Outdent;
22
+ /**
23
+ * Remove indentation from a string
24
+ * @param string_ The raw string to process.
25
+ * @returns The processed string with indentation removed.
26
+ */
5
27
  string: (string_: string) => string;
6
28
  }
29
+ /**
30
+ * Configuration options for the outdent function.
31
+ */
7
32
  interface Options {
33
+ /**
34
+ * Whether to cache processed template literals for better performance when
35
+ * using the same template multiple times.
36
+ *
37
+ * Enabling caching can significantly improve performance when the same template
38
+ * is used repeatedly, such as in loops or frequently called functions.
39
+ * @example
40
+ * // Create an outdent function with caching enabled (default)
41
+ * const dedent = outdent();
42
+ *
43
+ * // Create an outdent function with caching disabled
44
+ * const noCacheDedent = outdent({ cache: false });
45
+ * @default true
46
+ */
8
47
  cache?: boolean;
48
+ /**
49
+ * Custom cache store to use instead of the default WeakMap.
50
+ * Must be a WeakMap instance.
51
+ *
52
+ * This allows you to provide your own WeakMap instance for caching,
53
+ * which can be useful for advanced use cases or for sharing cache
54
+ * between multiple outdent instances.
55
+ * @example
56
+ * // Create a custom cache
57
+ * const customCache = new WeakMap();
58
+ *
59
+ * // Create an outdent function with a custom cache
60
+ * const customCacheDedent = outdent({ cacheStore: customCache });
61
+ */
9
62
  cacheStore?: WeakMap<TemplateStringsArray, string[]>;
63
+ /**
64
+ * Normalize all newlines in the template literal to this value.
65
+ *
66
+ * If `null`, newlines are left untouched.
67
+ *
68
+ * Newlines that get normalized are '\r\n', '\r', and '\n'.
69
+ *
70
+ * Newlines within interpolated values are *never* normalized.
71
+ *
72
+ * Although intended for normalizing to '\n' or '\r\n',
73
+ * you can also set to any string; for example ' '.
74
+ * @default null
75
+ */
10
76
  newline?: string | null;
77
+ /**
78
+ * Whether to trim the leading newline in the template literal.
79
+ * @default true
80
+ */
11
81
  trimLeadingNewline?: boolean;
82
+ /**
83
+ * Whether to trim the trailing newline in the template literal.
84
+ * @default true
85
+ */
12
86
  trimTrailingNewline?: boolean;
13
87
  }
14
88
  export { Options, Outdent, outdent };
package/dist/outdent.js CHANGED
@@ -1,109 +1 @@
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
-
3
- const has = (object, property) => Object.hasOwn(object, property);
4
- const extend = (target, source) => Object.assign(target, source);
5
- const internalOutdentArray = (strings, firstInterpolatedValueSetsIndentationLevel, options) => {
6
- if (strings.length === 0) {
7
- return [];
8
- }
9
- let indentationLevel = 0;
10
- const match = RE_DETECT_INDENTATION.exec(strings[0]);
11
- if (match) {
12
- indentationLevel = match[1].length;
13
- }
14
- const reSource = String.raw`(\r\n|\r|\n).{0,${indentationLevel}}`;
15
- const reMatchIndent = new RegExp(reSource, "g");
16
- const processedStrings = firstInterpolatedValueSetsIndentationLevel ? strings.slice(1) : strings;
17
- const { newline, trimLeadingNewline, trimTrailingNewline } = options;
18
- const normalizeNewlines = typeof newline === "string";
19
- const l = processedStrings.length;
20
- const outdentedStrings = Array.from({ length: l });
21
- for (let index = 0; index < l; index++) {
22
- let v = processedStrings[index];
23
- v = v.replace(reMatchIndent, "$1");
24
- if (index === 0 && trimLeadingNewline) {
25
- v = v.replace(RE_LEADING_NEWLINE, "");
26
- }
27
- if (index === l - 1 && trimTrailingNewline) {
28
- v = v.replace(RE_TRAILING_NEWLINE, "");
29
- }
30
- if (normalizeNewlines) {
31
- v = v.replaceAll(RE_MATCH_NEWLINES, newline);
32
- }
33
- outdentedStrings[index] = v;
34
- }
35
- return outdentedStrings;
36
- };
37
- const concatStringsAndValues = (strings, values) => {
38
- const chunks = Array.from({ length: strings.length + values.length });
39
- let index = 0;
40
- const l = strings.length;
41
- for (; index < l - 1; index++) {
42
- chunks[index * 2] = strings[index];
43
- chunks[index * 2 + 1] = String(values[index]);
44
- }
45
- chunks[index * 2] = strings[index];
46
- return chunks.join("");
47
- };
48
- const isTemplateStringsArray = (v) => has(v, "raw") && has(v, "length");
49
- const templateCache = /* @__PURE__ */ new WeakMap();
50
- const createInstance = (options) => {
51
- const enableCache = options.cache !== false;
52
- const cache = enableCache ? options.cacheStore ?? templateCache : void 0;
53
- const hasNewlineOption = options.newline !== void 0;
54
- function outdent2(stringsOrOptions, ...values) {
55
- if (isTemplateStringsArray(stringsOrOptions)) {
56
- const strings = stringsOrOptions;
57
- const valuesLength = values.length;
58
- if (strings.length === 1 && strings[0] === "") {
59
- return "";
60
- }
61
- if (valuesLength === 0) {
62
- if (enableCache && cache && !hasNewlineOption) {
63
- const cached = cache.get(strings);
64
- if (cached) {
65
- return cached[0];
66
- }
67
- }
68
- const result = internalOutdentArray(strings, false, options);
69
- if (enableCache && cache) {
70
- cache.set(strings, result);
71
- }
72
- return result[0];
73
- }
74
- const firstValueIsOutdent = values[0] === outdent2 || values[0] === defaultOutdent;
75
- const firstInterpolatedValueSetsIndentationLevel = firstValueIsOutdent && RE_ONLY_WHITESPACE_WITH_AT_LEAST_ONE_NEWLINE.test(strings[0]) && RE_STARTS_WITH_NEWLINE_OR_IS_EMPTY.test(strings[1]);
76
- let renderedArray;
77
- if (enableCache && cache && !hasNewlineOption) {
78
- renderedArray = cache.get(strings);
79
- }
80
- if (!renderedArray) {
81
- renderedArray = internalOutdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
82
- if (enableCache && cache) {
83
- cache.set(strings, renderedArray);
84
- }
85
- }
86
- return concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
87
- }
88
- return createInstance(extend(extend({}, options), stringsOrOptions));
89
- }
90
- return extend(outdent2, {
91
- string(string_) {
92
- if (string_ === "" || !string_) {
93
- return "";
94
- }
95
- return internalOutdentArray([string_], false, options)[0];
96
- }
97
- });
98
- };
99
- const defaultOutdent = createInstance({
100
- cache: true,
101
- // Enable caching by default
102
- // eslint-disable-next-line unicorn/no-null
103
- newline: null,
104
- trimLeadingNewline: true,
105
- trimTrailingNewline: true
106
- });
107
- const outdent = defaultOutdent;
108
-
109
- export { outdent };
1
+ import{f as A,g as R,h as p,i as S,j as W,k as m}from"./packem_shared/constants-aPzGW29R.js";const I=(e,r)=>Object.hasOwn(e,r),T=(e,r)=>Object.assign(e,r),h=(e,r,n)=>{if(e.length===0)return[];let t=0;const s=m.exec(e[0]);s&&(t=s[1].length);const i=String.raw`(\r\n|\r|\n).{0,${t}}`,g=new RegExp(i,"g"),l=r?e.slice(1):e,{newline:N,trimLeadingNewline:_,trimTrailingNewline:o}=n,f=typeof N=="string",E=l.length,u=Array.from({length:E});for(let c=0;c<E;c++){let a=l[c];a=a.replace(g,"$1"),c===0&&_&&(a=a.replace(A,"")),c===E-1&&o&&(a=a.replace(R,"")),f&&(a=a.replaceAll(W,N)),u[c]=a}return u},O=(e,r)=>{const n=Array.from({length:e.length+r.length});let t=0;const s=e.length;for(;t<s-1;t++)n[t*2]=e[t],n[t*2+1]=String(r[t]);return n[t*2]=e[t],n.join("")},d=e=>I(e,"raw")&&I(e,"length"),j=new WeakMap,w=e=>{const r=e.cache!==!1,n=r?e.cacheStore??j:void 0,t=e.newline!==void 0;function s(i,...g){if(d(i)){const l=i,N=g.length;if(l.length===1&&l[0]==="")return"";if(N===0){if(r&&n&&!t){const E=n.get(l);if(E)return E[0]}const f=h(l,!1,e);return r&&n&&n.set(l,f),f[0]}const _=(g[0]===s||g[0]===L)&&p.test(l[0])&&S.test(l[1]);let o;return r&&n&&!t&&(o=n.get(l)),o||(o=h(l,_,e),r&&n&&n.set(l,o)),O(o,_?g.slice(1):g)}return w(T(T({},e),i))}return T(s,{string(i){return i===""||!i?"":h([i],!1,e)[0]}})},L=w({cache:!0,newline:null,trimLeadingNewline:!0,trimTrailingNewline:!0}),b=L;export{b as outdent};
@@ -0,0 +1 @@
1
+ const r=[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],d=12288,m=65510,f=[12288,12288,65281,65376,65504,65510],g=8361,h=65518,w=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],M=32,C=10630,P=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],c=4352,b=262141,t=[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],u=(i,l)=>{let e=0,o=Math.floor(i.length/2)-1;for(;e<=o;){const n=Math.floor((e+o)/2),a=n*2;if(l<i[a])o=n-1;else if(l>i[a+1])e=n+1;else return!0}return!1},s=19968,[x,R]=W(t);function W(i){let l=i[0],e=i[1];for(let o=0;o<i.length;o+=2){const n=i[o],a=i[o+1];if(s>=n&&s<=a)return[n,a];a-n>e-l&&(l=n,e=a)}return[l,e]}const j=i=>i<161||i>1114109?!1:u(r,i),k=i=>i<d||i>m?!1:u(f,i),p=i=>i<g||i>h?!1:u(w,i),y=i=>i<M||i>C?!1:u(P,i),A=i=>i>=x&&i<=R?!0:i<c||i>b?!1:u(t,i);function E(i){return j(i)?"ambiguous":k(i)?"fullwidth":p(i)?"halfwidth":y(i)?"narrow":A(i)?"wide":"neutral"}export{E as getCategory,j as isAmbiguous,k as isFullWidth,A as isWide};
@@ -0,0 +1 @@
1
+ const i=new Uint32Array(65536),q=(r,l)=>{const o=r.length,n=l.length,a=1<<o-1;let c=-1,d=0,p=o,h=o;for(;h--;)i[r.charCodeAt(h)]|=1<<h;for(h=0;h<n;h++){let A=i[l.charCodeAt(h)];const g=A|d;A|=(A&c)+c^c,d|=~(A|c),c&=A,d&a&&p++,c&a&&p--,d=d<<1|1,c=c<<1|~(g|d),d&=g}for(h=o;h--;)i[r.charCodeAt(h)]=0;return p},z=(r,l)=>{const o=l.length,n=r.length,a=[],c=[],d=Math.ceil(o/32),p=Math.ceil(n/32);for(let t=0;t<d;t++)c[t]=-1,a[t]=0;let h=0;for(;h<p-1;h++){let t=0,s=-1;const M=h*32,u=Math.min(32,n)+M;for(let e=M;e<u;e++)i[r.charCodeAt(e)]|=1<<e;for(let e=0;e<o;e++){const m=i[l.charCodeAt(e)],C=c[e/32|0]>>>e&1,f=a[e/32|0]>>>e&1,j=m|t,k=((m|f)&s)+s^s|m|f;let x=t|~(k|s),w=s&k;x>>>31^C&&(c[e/32|0]^=1<<e),w>>>31^f&&(a[e/32|0]^=1<<e),x=x<<1|C,w=w<<1|f,s=w|~(j|x),t=x&j}for(let e=M;e<u;e++)i[r.charCodeAt(e)]=0}let A=0,g=-1;const v=h*32,U=Math.min(32,n-v)+v;for(let t=v;t<U;t++)i[r.charCodeAt(t)]|=1<<t;let y=n;for(let t=0;t<o;t++){const s=i[l.charCodeAt(t)],M=c[t/32|0]>>>t&1,u=a[t/32|0]>>>t&1,e=s|A,m=((s|u)&g)+g^g|s|u;let C=A|~(m|g),f=g&m;y+=C>>>n-1&1,y-=f>>>n-1&1,C>>>31^M&&(c[t/32|0]^=1<<t),f>>>31^u&&(a[t/32|0]^=1<<t),C=C<<1|M,f=f<<1|u,g=f|~(e|C),A=C&e}for(let t=v;t<U;t++)i[r.charCodeAt(t)]=0;return y},I=(r,l)=>{if(r.length<l.length){const o=l;l=r,r=o}return l.length===0?r.length:r.length<=32?q(r,l):z(r,l)},_=(r,l)=>{let o=1/0,n=0;for(let a=0;a<l.length;a++){const c=I(r,l[a]);c<o&&(o=c,n=a)}return l[n]};export{_ as closest,I as distance};
@@ -0,0 +1 @@
1
+ const R=String.raw,E=R`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,a=()=>new RegExp(R`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${E}(?:\u200D${E})*`,"gu"),n=new Set(["\x1B","›"]),e="\x07",_="[",r="m",u="]8;;",S=39,s=/[\u200B\uFEFF\u2060-\u2064]/g,I=new RegExp(`(?:\\${_}(?<code>\\d+)m|\\${u}(?<uri>.*)${e})`),i=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),t=/^[ \t]*(?:\r\n|\r|\n)/,N=/(?:\r\n|\r|\n)[ \t]*$/,g=/^(?:[\r\n]|$)/,c=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,T=/^[ \t]*[\r\n][ \t\r\n]*$/,L=/\r\n|\n|\r/g,w=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,x=/\u001B\[[\d;]*m[^\u001B]*(?:\u001B\[[\d;]*m|$)/g,B=/\u001B\]8;[^\u0007\u001B]*(?:\u0007|\u001B\\)[^\u001B]*\u001B\]8;;(?:\u0007|\u001B\\)/g,O=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,A=a(),H=/[-_./\s]+/g,C=/(\u001B\[[0-9;]*[a-z])/i,G=new RegExp("\\p{Script=Arabic}","u"),M=new RegExp("\\p{Script=Bengali}","u"),D=new RegExp("\\p{Script=Cyrillic}","u"),K=new RegExp("\\p{Script=Devanagari}","u"),F=new RegExp("\\p{Script=Ethiopic}","u"),P=new RegExp("\\p{Script=Greek}","u"),m=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),l=new RegExp("\\p{Script=Gujarati}","u"),o=new RegExp("\\p{Script=Gurmukhi}","u"),W=new RegExp("\\p{Script=Hangul}","u"),d=new RegExp("\\p{Script=Hebrew}","u"),$=new RegExp("\\p{Script=Hiragana}","u"),U=new RegExp("\\p{Script=Han}","u"),y=new RegExp("\\p{Script=Kannada}","u"),Y=new RegExp("\\p{Script=Katakana}","u"),h=new RegExp("\\p{Script=Khmer}","u"),k=new RegExp("\\p{Script=Lao}","u"),b=new RegExp("\\p{Script=Latin}","u"),j=new RegExp("\\p{Script=Malayalam}","u"),J=new RegExp("\\p{Script=Myanmar}","u"),V=new RegExp("\\p{Script=Oriya}","u"),f=new RegExp("\\p{Script=Sinhala}","u"),z=new RegExp("\\p{Script=Tamil}","u"),Z=new RegExp("\\p{Script=Telugu}","u"),q=new RegExp("\\p{Script=Thai}","u"),v=new RegExp("\\p{Script=Tibetan}","u"),Q=/[\u02BB\u02BC\u0027]/u,X=p=>p.replace(A,"");export{l as A,o as B,y as C,z as D,Z as E,j as F,f as G,q as H,k as I,v as J,J as K,F as L,h as M,V as N,n as O,r as P,u as Q,w as R,e as S,_ as T,I as U,i as V,S as W,s as X,O as a,A as b,C as c,x as d,B as e,t as f,N as g,T as h,g as i,L as j,c as k,H as l,D as m,b as n,P as o,m as p,Q as q,Y as r,X as s,U as t,$ as u,W as v,d as w,G as x,K as y,M as z};
@@ -0,0 +1 @@
1
+ function I(e){const t=e.match(/^[ \t]*(?=\S)/gm);if(!t)return e;let n=Number.POSITIVE_INFINITY;for(const r of t)n=Math.min(n,r.length);return n===0||n===Number.POSITIVE_INFINITY?e:e.replace(new RegExp(`^[ \\t]{${n}}`,"gm"),"")}function c(e){const t=e.replace(/^(?:[ \t]*\r?\n)+|(?:\r?\n[ \t]*)+$/g,"");return I(t)}export{c as dedent,I as default};
@@ -0,0 +1 @@
1
+ import{isFullWidth as s,isWide as o,isAmbiguous as r,getCategory as n}from"./_isFullWidth-Dqc3MWgl.js";function t(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function a(e){return t(e),n(e)}function d(e,{ambiguousAsWide:i=!1}={}){return t(e),s(e)||o(e)||i&&r(e)?2:1}export{s as _isFullWidth,o as _isWide,d as eastAsianWidth,a as eastAsianWidthType};
@@ -0,0 +1 @@
1
+ const s=(r,n)=>`${r}::${n?.joiner??""}::${n?.locale??""}::${n?.knownAcronyms?.join(",")??""}::${n?.normalize?"true":"false"}::${n?.stripAnsi?"true":"false"}::${n?.stripEmoji?"true":"false"}::${n?.handleAnsi?"true":"false"}::${n?.handleEmoji?"true":"false"}`;export{s as a};
@@ -0,0 +1 @@
1
+ function i(e,t=1,r={}){const{indent:o=" ",includeEmptyLines:n=!1}=r;if(typeof e!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``);if(typeof t!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof t}\``);if(t<0)throw new RangeError(`Expected \`count\` to be at least 0, got \`${t}\``);if(typeof o!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof o}\``);if(t===0)return e;const p=n?/^/gm:/^(?!\s*$)/gm;return e.replace(p,o.repeat(t))}export{i as default};
@@ -0,0 +1 @@
1
+ import{c as h}from"./constants-aPzGW29R.js";const l=(o,u)=>{const{length:r}=o;if(r===0)return"";if(r===1)return o[0];const t=[];let n="",e="";for(let f=0;f<r;f++){const s=o[f];if(h.test(s)){n?(t.push(n+e+s),n="",e=""):(t.length>0&&t.push(u),n=s);continue}n?(e&&(e+=u),e+=s):(t.length>0&&t.push(u),t.push(s))}return t.join("")};export{l as default};
@@ -0,0 +1 @@
1
+ class s{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const c=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,c),c}has(e){return this.cache.has(e)}set(e,c){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const t=this.cache.keys().next().value;t!==void 0&&this.cache.delete(t)}this.cache.set(e,c)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}}export{s as i};
@@ -0,0 +1 @@
1
+ const e=/(?<![a-zß])SS(?![a-z])/g,l=a=>a.replaceAll(e,"ß");export{l as a};
@@ -0,0 +1 @@
1
+ import f from"./indent-cz8WMI0e.js";import i from"./dedent-CPjAYUXh.js";function n(r,o=0,t={}){return f(i(r),o,t)}export{n as default};