@visulima/string 3.0.0-alpha.11 → 3.0.0-alpha.12

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 (114) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE.md +68 -3
  3. package/dist/align-text.d.ts +35 -0
  4. package/dist/align-text.js +2 -34
  5. package/dist/case/camel-case.d.ts +17 -2
  6. package/dist/case/camel-case.js +1 -55
  7. package/dist/case/capital-case.d.ts +14 -2
  8. package/dist/case/capital-case.js +1 -47
  9. package/dist/case/constant-case.d.ts +14 -2
  10. package/dist/case/constant-case.js +1 -7
  11. package/dist/case/dot-case.d.ts +14 -2
  12. package/dist/case/dot-case.js +1 -7
  13. package/dist/case/flat-case.d.ts +12 -2
  14. package/dist/case/flat-case.js +1 -7
  15. package/dist/case/flip-case.d.ts +16 -2
  16. package/dist/case/flip-case.js +1 -82
  17. package/dist/case/identify-case.d.ts +15 -2
  18. package/dist/case/identify-case.js +1 -66
  19. package/dist/case/index.d.ts +8 -2
  20. package/dist/case/index.js +1 -20
  21. package/dist/case/kebab-case.d.ts +25 -2
  22. package/dist/case/kebab-case.js +1 -55
  23. package/dist/case/lower-first.d.ts +13 -2
  24. package/dist/case/lower-first.js +1 -9
  25. package/dist/case/no-case.d.ts +14 -2
  26. package/dist/case/no-case.js +1 -7
  27. package/dist/case/pascal-case.d.ts +17 -2
  28. package/dist/case/pascal-case.js +1 -48
  29. package/dist/case/pascal-snake-case.d.ts +14 -2
  30. package/dist/case/pascal-snake-case.js +1 -28
  31. package/dist/case/path-case.d.ts +14 -2
  32. package/dist/case/path-case.js +1 -7
  33. package/dist/case/sentence-case.d.ts +14 -2
  34. package/dist/case/sentence-case.js +1 -54
  35. package/dist/case/snake-case.d.ts +14 -2
  36. package/dist/case/snake-case.js +1 -7
  37. package/dist/case/split-by-case.d.ts +29 -2
  38. package/dist/case/split-by-case.js +1 -763
  39. package/dist/case/title-case.d.ts +12 -2
  40. package/dist/case/title-case.js +1 -40
  41. package/dist/case/train-case.d.ts +14 -2
  42. package/dist/case/train-case.js +1 -40
  43. package/dist/case/upper-first.d.ts +13 -2
  44. package/dist/case/upper-first.js +1 -9
  45. package/dist/closest-string.d.ts +32 -0
  46. package/dist/closest-string.js +1 -22
  47. package/dist/compare-similarity.d.ts +38 -1
  48. package/dist/compare-similarity.js +1 -12
  49. package/dist/get-string-truncated-width.d.ts +151 -0
  50. package/dist/get-string-truncated-width.js +1 -332
  51. package/dist/get-string-width.d.ts +58 -0
  52. package/dist/get-string-width.js +1 -5
  53. package/dist/index.d.ts +194 -9
  54. package/dist/index.js +1 -44
  55. package/dist/native-string-types.d.ts +239 -0
  56. package/dist/outdent.d.ts +74 -0
  57. package/dist/outdent.js +1 -109
  58. package/dist/packem_shared/LRUCache-Bjo6gsbC.js +1 -0
  59. package/dist/packem_shared/closest-uarbVSbs.js +1 -0
  60. package/dist/packem_shared/closestN-Vd5oNJy_.js +1 -0
  61. package/dist/packem_shared/constants-DmzZF6_u.js +1 -0
  62. package/dist/packem_shared/countOccurrences-DIHSCdcG.js +1 -0
  63. package/dist/packem_shared/direction-dtczwUOE.js +1 -0
  64. package/dist/packem_shared/eastAsianWidthType-lcBsj7vg.js +1 -0
  65. package/dist/packem_shared/excerpt-DhV2yoHG.js +54 -0
  66. package/dist/packem_shared/generate-cache-key-DPByFaMH.js +1 -0
  67. package/dist/packem_shared/indent-CDlPQmpe.js +1 -0
  68. package/dist/packem_shared/isFullwidthCodePoint-Dmsf2-5L.js +1 -0
  69. package/dist/packem_shared/joinSegments-D27SxoCV.js +1 -0
  70. package/dist/packem_shared/lookup-ChWuUpyb.js +1 -0
  71. package/dist/packem_shared/normalize-german-eszett-AKfdw2MZ.js +1 -0
  72. package/dist/packem_shared/redent-BECVOaZp.js +1 -0
  73. package/dist/packem_shared/replaceString-aq-C7Wor.js +1 -0
  74. package/dist/packem_shared/stripIndent-Dt8hSxVM.js +1 -0
  75. package/dist/packem_shared/transliterate-D1p1yYE7.js +5 -0
  76. package/dist/packem_shared/types.d-FOLSY2Tc.d.ts +392 -0
  77. package/dist/packem_shared/types.d-NJ4vcG-A.d.ts +346 -0
  78. package/dist/slice.d.ts +42 -0
  79. package/dist/slice.js +1 -415
  80. package/dist/slugify.d.ts +10 -1
  81. package/dist/slugify.js +1 -46
  82. package/dist/test/utils.d.ts +17 -0
  83. package/dist/test/utils.js +13 -88
  84. package/dist/test/vitest.d.ts +3 -0
  85. package/dist/test/vitest.js +1 -5
  86. package/dist/truncate.d.ts +43 -0
  87. package/dist/truncate.js +1 -112
  88. package/dist/utilities.d.ts +28 -1
  89. package/dist/utilities.js +1 -52
  90. package/dist/word-similarity-sort.d.ts +34 -0
  91. package/dist/word-similarity-sort.js +1 -22
  92. package/dist/word-wrap.d.ts +44 -0
  93. package/dist/word-wrap.js +8 -639
  94. package/package.json +46 -46
  95. package/dist/packem_shared/LRUCache-3r3SovvR.js +0 -46
  96. package/dist/packem_shared/closest-IHuSvnSn.js +0 -139
  97. package/dist/packem_shared/closestN-DUsjgiXb.js +0 -25
  98. package/dist/packem_shared/constants-BsZS5f0z.js +0 -95
  99. package/dist/packem_shared/countOccurrences-CS9XprQN.js +0 -22
  100. package/dist/packem_shared/direction-C9gfWWTK.js +0 -16
  101. package/dist/packem_shared/eastAsianWidthType-SD3YniiT.js +0 -20
  102. package/dist/packem_shared/excerpt-COsVNttN.js +0 -1502
  103. package/dist/packem_shared/generate-cache-key-DdayDfjV.js +0 -6
  104. package/dist/packem_shared/indent-D3DSCa6s.js +0 -33
  105. package/dist/packem_shared/isFullwidthCodePoint-IFXZxNjq.js +0 -10
  106. package/dist/packem_shared/joinSegments-CvxSgKz0.js +0 -44
  107. package/dist/packem_shared/lookup-BE8lEqy4.js +0 -104
  108. package/dist/packem_shared/normalize-german-eszett-4p3yKEzn.js +0 -8
  109. package/dist/packem_shared/redent-DSb1IJWn.js +0 -8
  110. package/dist/packem_shared/replaceString-Ce8X2ZQ-.js +0 -192
  111. package/dist/packem_shared/stripIndent-D_TRjxZ_.js +0 -20
  112. package/dist/packem_shared/transliterate-CKt9VK7D.js +0 -47756
  113. package/dist/packem_shared/types.d-BVNv675q.d.ts +0 -61
  114. package/dist/packem_shared/types.d-DfgbcNKh.d.ts +0 -57
@@ -0,0 +1,392 @@
1
+ import { I as IsStringLiteral, N as NodeLocale } from "./types.d-NJ4vcG-A.js";
2
+ import { L as LRUCache } from "./lru-cache.d-BsP6kbVJ.js";
3
+ /**
4
+ * Valid characters used to split strings into words.
5
+ * Used by various case conversion functions to identify word boundaries.
6
+ * @type {string}
7
+ */
8
+ type SplitterCharacter = " " | "_" | "-" | "." | "/";
9
+ /**
10
+ * Gets the type of the last element in an array type.
11
+ * @template T - The array type to extract from
12
+ * @returns The type of the last element, or never if array is empty
13
+ */
14
+ type LastOfArray<T extends any[]> = T extends [...any, infer R] ? R : never;
15
+ /**
16
+ * Creates a new array type with the last element removed.
17
+ * @template T - The array type to modify
18
+ * @returns A new array type without the last element, or never if array is empty
19
+ */
20
+ type RemoveLastOfArray<T extends any[]> = T extends [...infer F, any] ? F : never;
21
+ /**
22
+ * Type predicate that checks if a string type contains only uppercase characters.
23
+ * @template S - The string type to check
24
+ * @returns true if string is all uppercase, false otherwise
25
+ * @example
26
+ * type IsUpper = IsUpperCase<'ABC'> // type IsUpper = true
27
+ * type NotUpper = IsUpperCase<'aBc'> // type NotUpper = false
28
+ */
29
+ type IsUpperCase<S extends string> = S extends Uppercase<S> ? true : false;
30
+ /**
31
+ * Type predicate that checks if a string type contains only lowercase characters.
32
+ * @template S - The string type to check
33
+ * @returns true if string is all lowercase, false otherwise
34
+ * @example
35
+ * type IsLower = IsLowerCase<'abc'> // type IsLower = true
36
+ * type NotLower = IsLowerCase<'aBc'> // type NotLower = false
37
+ */
38
+ type IsLowerCase<S extends string> = S extends Lowercase<S> ? true : false;
39
+ /**
40
+ * Type predicate that checks if two string types have the same case pattern.
41
+ * Both strings must be either all uppercase or all lowercase to be considered the same case.
42
+ * @template X - First string type to compare
43
+ * @template Y - Second string type to compare
44
+ * @returns true if both strings have the same case pattern, false otherwise
45
+ * @example
46
+ * type Same = SameLetterCase<'ABC', 'XYZ'> // type Same = true
47
+ * type Different = SameLetterCase<'abc', 'XYZ'> // type Different = false
48
+ */
49
+ type SameLetterCase<X extends string, Y extends string> = IsUpperCase<X> extends IsUpperCase<Y> ? true : IsLowerCase<X> extends IsLowerCase<Y> ? true : false;
50
+ /**
51
+ * Gets the first character of a string type.
52
+ * @template S - The string type to extract from
53
+ * @returns The first character as a string type, or never if string is empty
54
+ * @example
55
+ * type First = FirstOfString<'hello'> // type First = 'h'
56
+ */
57
+ type FirstOfString<S extends string> = S extends `${infer F}${string}` ? F : never;
58
+ /**
59
+ * Creates a new string type with the first character removed.
60
+ * @template S - The string type to modify
61
+ * @returns A new string type without the first character, or never if string is empty
62
+ * @example
63
+ * type Rest = RemoveFirstOfString<'hello'> // type Rest = 'ello'
64
+ */
65
+ type RemoveFirstOfString<S extends string> = S extends `${string}${infer R}` ? R : never;
66
+ /**
67
+ * Options for locale support.
68
+ */
69
+ interface LocaleOptions {
70
+ /**
71
+ * The locale to use for case conversion.
72
+ * If not provided, the system default locale will be used.
73
+ */
74
+ locale?: NodeLocale;
75
+ }
76
+ /**
77
+ * Options for case conversion with locale support.
78
+ */
79
+ interface CaseOptions extends LocaleOptions {
80
+ /**
81
+ * Uses a shared LRU cache with a fixed size.
82
+ * @default false
83
+ */
84
+ cache?: boolean;
85
+ /**
86
+ * A custom cache store for this specific case function.
87
+ * Each case function (camelCase, pascalCase, etc.) should have its own dedicated cache store
88
+ * to avoid conflicts and ensure optimal performance.
89
+ * @example
90
+ * ```typescript
91
+ * // Create separate caches for each case function
92
+ * const camelCaseStore = new LRUCache<string, string>(1000);
93
+ * const pascalCaseStore = new LRUCache<string, string>(1000);
94
+ *
95
+ * camelCase("some-string", { cache: true, cacheStore: camelCaseStore });
96
+ * pascalCase("some-string", { cache: true, cacheStore: pascalCaseStore });
97
+ * ```
98
+ */
99
+ cacheStore?: LRUCache<string, string>;
100
+ /**
101
+ * Whether to handle ANSI escape sequences.
102
+ * @default false
103
+ */
104
+ handleAnsi?: boolean;
105
+ /**
106
+ * Whether to handle emoji sequences.
107
+ * @default false
108
+ */
109
+ handleEmoji?: boolean;
110
+ /**
111
+ * A list of known acronyms to preserve casing for.
112
+ */
113
+ knownAcronyms?: ReadonlyArray<string>;
114
+ /**
115
+ * Whether to normalize case (e.g., convert uppercase tokens not in knownAcronyms to title case).
116
+ */
117
+ normalize?: boolean;
118
+ /**
119
+ * Whether to strip ANSI escape sequences. (default: false)
120
+ */
121
+ stripAnsi?: boolean;
122
+ /**
123
+ * Whether to strip emoji sequences. (default: false)
124
+ */
125
+ stripEmoji?: boolean;
126
+ }
127
+ /**
128
+ * Type-level implementation of camelCase conversion.
129
+ * Converts a string type to camelCase format where words are joined together
130
+ * with the first word in lowercase and subsequent words capitalized.
131
+ * @template T - The string type to convert
132
+ * @returns A string type in camelCase format
133
+ * @example
134
+ * type Result1 = CamelCase<'foo bar'> // type Result1 = 'fooBar'
135
+ * type Result2 = CamelCase<'foo-bar'> // type Result2 = 'fooBar'
136
+ * type Result3 = CamelCase<'foo_bar'> // type Result3 = 'fooBar'
137
+ */
138
+ type CamelCase<T extends string> = IsStringLiteral<T> extends true ? T extends `${infer F}_${infer R}` ? `${Lowercase<F>}${Capitalize<CamelCase<R>>}` : T extends `${infer F}-${infer R}` ? `${Lowercase<F>}${Capitalize<CamelCase<R>>}` : T extends `${infer F} ${infer R}` ? `${Lowercase<F>}${Capitalize<CamelCase<R>>}` : Lowercase<T> : string;
139
+ /**
140
+ * Type-level implementation of PascalCase conversion.
141
+ * Converts a string type to PascalCase format where words are joined together
142
+ * with each word capitalized.
143
+ * @template T - The string type to convert
144
+ * @returns A string type in PascalCase format
145
+ * @example
146
+ * type Result1 = PascalCase<'foo bar'> // type Result1 = 'FooBar'
147
+ * type Result2 = PascalCase<'foo-bar'> // type Result2 = 'FooBar'
148
+ * type Result3 = PascalCase<'foo_bar'> // type Result3 = 'FooBar'
149
+ */
150
+ type PascalCase<T extends string> = IsStringLiteral<T> extends true ? Capitalize<CamelCase<T>> : string;
151
+ /**
152
+ * Type-level implementation of snake_case conversion.
153
+ * Converts a string type to snake_case format where words are in lowercase
154
+ * and separated by underscores.
155
+ * @template T - The string type to convert
156
+ * @returns A string type in snake_case format
157
+ * @example
158
+ * type Result1 = SnakeCase<'fooBar'> // type Result1 = 'foo_bar'
159
+ * type Result2 = SnakeCase<'foo bar'> // type Result2 = 'foo_bar'
160
+ * type Result3 = SnakeCase<'foo-bar'> // type Result3 = 'foo_bar'
161
+ */
162
+ type SnakeCase<T extends string> = IsStringLiteral<T> extends true ? T extends `${infer C}${infer Rest}` ? C extends Uppercase<C> ? `_${Lowercase<C>}${SnakeCase<Rest>}` : `${C}${SnakeCase<Rest>}` : T : string;
163
+ /**
164
+ * Type-level implementation of kebab-case conversion.
165
+ * Converts a string type to kebab-case format where words are in lowercase
166
+ * and separated by hyphens.
167
+ * @template T - The string type to convert
168
+ * @returns A string type in kebab-case format
169
+ * @example
170
+ * type Result1 = KebabCase<'fooBar'> // type Result1 = 'foo-bar'
171
+ * type Result2 = KebabCase<'foo bar'> // type Result2 = 'foo-bar'
172
+ * type Result3 = KebabCase<'foo_bar'> // type Result3 = 'foo-bar'
173
+ */
174
+ type KebabCase<T extends string> = IsStringLiteral<T> extends true ? T extends `${infer C}${infer Rest}` ? C extends Uppercase<C> ? `-${Lowercase<C>}${KebabCase<Rest>}` : `${C}${KebabCase<Rest>}` : T : string;
175
+ /**
176
+ * Type-level implementation of flat case conversion.
177
+ * Converts a string type to flat case format where all words are joined together
178
+ * in lowercase with no separators.
179
+ * @template T - The string type to convert
180
+ * @returns A string type in flat case format
181
+ * @example
182
+ * type Result1 = FlatCase<'foo-barBaz'> // type Result1 = 'foobarbaz'
183
+ * type Result2 = FlatCase<'foo bar'> // type Result2 = 'foobar'
184
+ * type Result3 = FlatCase<'FOO_BAR'> // type Result3 = 'foobar'
185
+ */
186
+ type FlatCase<T extends string> = IsStringLiteral<T> extends true ? Lowercase<T extends `${infer F}${infer R}` ? `${F}${FlatCase<R>}` : T> : string;
187
+ /**
188
+ * Type-level implementation of Train-Case conversion.
189
+ * Converts a string type to Train-Case format where words are capitalized
190
+ * and separated by hyphens. This case style is similar to PascalCase but with
191
+ * hyphens between words.
192
+ * @template T - The string type to convert
193
+ * @returns A string type in Train-Case format
194
+ * @example
195
+ * type Result1 = TrainCase<'FooBARb'> // type Result1 = 'Foo-Ba-Rb'
196
+ * type Result2 = TrainCase<'foo bar'> // type Result2 = 'Foo-Bar'
197
+ * type Result3 = TrainCase<'foo_bar'> // type Result3 = 'Foo-Bar'
198
+ */
199
+ type TrainCase<T extends string, N extends boolean = false> = IsStringLiteral<T> extends true ? T extends `${infer F}${infer R}` ? F extends Uppercase<F> ? R extends `${infer Next}${infer Rest}` ? Next extends Uppercase<Next> ? N extends true ? `${Capitalize<F>}-${Lowercase<Next>}${TrainCase<Rest, N>}` : `${F}${Next}${TrainCase<Rest, N>}` : `${Capitalize<F>}${TrainCase<R, N>}` : `${Capitalize<F>}${Lowercase<R>}` : `${Lowercase<F>}${TrainCase<R, N>}` : T : string;
200
+ /**
201
+ * Type-level implementation of Title Case conversion.
202
+ * Converts a string type to Title Case format where the first letter of each
203
+ * significant word is capitalized. Articles, conjunctions, and prepositions
204
+ * typically remain in lowercase unless they are the first word.
205
+ * @template T - The string type to convert
206
+ * @returns A string type in Title Case format
207
+ * @example
208
+ * type Result1 = TitleCase<'this-IS-aTitle'> // type Result1 = 'This Is A Title'
209
+ * type Result2 = TitleCase<'hello_world'> // type Result2 = 'Hello World'
210
+ * type Result3 = TitleCase<'theFox'> // type Result3 = 'The Fox'
211
+ */
212
+ type TitleCase<T extends string> = IsStringLiteral<T> extends true ? (T extends `${infer F}${infer R}` ? `${Capitalize<F>}${Lowercase<R>}` : T) : string;
213
+ /**
214
+ * Type-level implementation of first character capitalization.
215
+ * Converts the first character of a string type to uppercase while leaving
216
+ * the rest of the string unchanged.
217
+ * @template T - The string type to modify
218
+ * @returns A string type with its first character in uppercase
219
+ * @example
220
+ * type Result1 = UpperFirst<'hello world!'> // type Result1 = 'Hello world!'
221
+ * type Result2 = UpperFirst<'fooBar'> // type Result2 = 'FooBar'
222
+ * type Result3 = UpperFirst<'123abc'> // type Result3 = '123abc'
223
+ */
224
+ type UpperFirst<T extends string> = IsStringLiteral<T> extends true ? (T extends `${infer F}${infer R}` ? `${Uppercase<F>}${R}` : T) : string;
225
+ /**
226
+ * Type-level implementation of first character lowercasing.
227
+ * Converts the first character of a string type to lowercase while leaving
228
+ * the rest of the string unchanged.
229
+ * @template T - The string type to modify
230
+ * @returns A string type with its first character in lowercase
231
+ * @example
232
+ * type Result1 = LowerFirst<'Hello world!'> // type Result1 = 'hello world!'
233
+ * type Result2 = LowerFirst<'FooBar'> // type Result2 = 'fooBar'
234
+ * type Result3 = LowerFirst<'123ABC'> // type Result3 = '123ABC'
235
+ */
236
+ type LowerFirst<T extends string> = IsStringLiteral<T> extends true ? (T extends `${infer F}${infer R}` ? `${Lowercase<F>}${R}` : T) : string;
237
+ /**
238
+ * Type-level implementation of case flipping.
239
+ * Inverts the case of each character in a string type - uppercase becomes
240
+ * lowercase and vice versa.
241
+ * @template T - The string type to modify
242
+ * @returns A string type with inverted character cases
243
+ * @example
244
+ * type Result1 = FlipCase<'FooBar'> // type Result1 = 'fOObAR'
245
+ * type Result2 = FlipCase<'Hello World'> // type Result2 = 'hELLO wORLD'
246
+ * type Result3 = FlipCase<'123'> // type Result3 = '123'
247
+ */
248
+ type FlipCase<T extends string> = IsStringLiteral<T> extends true ? T extends `${infer C}${infer Rest}` ? `${C extends Uppercase<C> ? Lowercase<C> : Uppercase<C>}${FlipCase<Rest>}` : T : string;
249
+ /**
250
+ * Type-level implementation of dot.case conversion.
251
+ * Converts a string type to dot.case format where words are in lowercase
252
+ * and separated by dots.
253
+ * @template T - The string type to convert
254
+ * @returns A string type in dot.case format
255
+ * @example
256
+ * type Result1 = DotCase<'fooBar'> // type Result1 = 'foo.bar'
257
+ * type Result2 = DotCase<'foo_bar'> // type Result2 = 'foo.bar'
258
+ * type Result3 = DotCase<'foo-bar'> // type Result3 = 'foo.bar'
259
+ */
260
+ type DotCase<T extends string> = T & {
261
+ __dot_case__: never;
262
+ };
263
+ /**
264
+ * Type-level implementation of path/case conversion.
265
+ * Converts a string type to path/case format where words are in lowercase
266
+ * and separated by forward slashes, making it suitable for file paths.
267
+ * @template T - The string type to convert
268
+ * @returns A string type in path/case format
269
+ * @example
270
+ * type Result1 = PathCase<'fooBar'> // type Result1 = 'foo/bar'
271
+ * type Result2 = PathCase<'foo_bar'> // type Result2 = 'foo/bar'
272
+ * type Result3 = PathCase<'foo-bar'> // type Result3 = 'foo/bar'
273
+ */
274
+ type PathCase<T extends string> = T & {
275
+ __path_case__: never;
276
+ };
277
+ /**
278
+ * Type-level implementation of no case conversion.
279
+ * Converts a string type to space-separated lowercase words, removing all
280
+ * special case formatting.
281
+ * @template T - The string type to convert
282
+ * @returns A string type in space-separated lowercase format
283
+ * @example
284
+ * type Result1 = NoCase<'fooBar'> // type Result1 = 'foo bar'
285
+ * type Result2 = NoCase<'foo_bar'> // type Result2 = 'foo bar'
286
+ * type Result3 = NoCase<'FOO-BAR'> // type Result3 = 'foo bar'
287
+ */
288
+ type NoCase<T extends string> = T & {
289
+ __no_case__: never;
290
+ };
291
+ /**
292
+ * Type-level implementation of CONSTANT_CASE conversion.
293
+ * Converts a string type to CONSTANT_CASE format where words are in uppercase
294
+ * and separated by underscores. Commonly used for constant/enum values.
295
+ * @template T - The string type to convert
296
+ * @returns A string type in CONSTANT_CASE format
297
+ * @example
298
+ * type Result1 = ConstantCase<'fooBar'> // type Result1 = 'FOO_BAR'
299
+ * type Result2 = ConstantCase<'foo-bar'> // type Result2 = 'FOO_BAR'
300
+ * type Result3 = ConstantCase<'foo bar'> // type Result3 = 'FOO_BAR'
301
+ */
302
+ type ConstantCase<T extends string> = T & {
303
+ __constant_case__: never;
304
+ };
305
+ /**
306
+ * Type-level implementation of Capital Case conversion.
307
+ * Converts a string type to Capital Case format where each word starts with
308
+ * a capital letter and words are separated by spaces.
309
+ * @template T - The string type to convert
310
+ * @returns A string type in Capital Case format
311
+ * @example
312
+ * type Result1 = CapitalCase<'fooBar'> // type Result1 = 'Foo Bar'
313
+ * type Result2 = CapitalCase<'foo_bar'> // type Result2 = 'Foo Bar'
314
+ * type Result3 = CapitalCase<'foo-bar'> // type Result3 = 'Foo Bar'
315
+ */
316
+ type CapitalCase<T extends string> = T & {
317
+ __capital_case__: never;
318
+ };
319
+ /**
320
+ * Type-level implementation of Sentence case conversion.
321
+ * Converts a string type to Sentence case format where only the first word
322
+ * starts with a capital letter and all other words are lowercase.
323
+ * @template T - The string type to convert
324
+ * @returns A string type in Sentence case format
325
+ * @example
326
+ * type Result1 = SentenceCase<'fooBar'> // type Result1 = 'Foo bar'
327
+ * type Result2 = SentenceCase<'FOO_BAR'> // type Result2 = 'Foo bar'
328
+ * type Result3 = SentenceCase<'foo-bar'> // type Result3 = 'Foo bar'
329
+ */
330
+ type SentenceCase<T extends string> = T & {
331
+ __sentence_case__: never;
332
+ };
333
+ /**
334
+ * Type-level implementation of Pascal_Snake_Case conversion.
335
+ * Converts a string type to Pascal_Snake_Case format where words are capitalized
336
+ * and separated by underscores. This is a hybrid between PascalCase and snake_case.
337
+ * @template T - The string type to convert
338
+ * @returns A string type in Pascal_Snake_Case format
339
+ * @example
340
+ * type Result1 = PascalSnakeCase<'fooBar'> // type Result1 = 'Foo_Bar'
341
+ * type Result2 = PascalSnakeCase<'foo bar'> // type Result2 = 'Foo_Bar'
342
+ * type Result3 = PascalSnakeCase<'foo-bar'> // type Result3 = 'Foo_Bar'
343
+ */
344
+ type PascalSnakeCase<T extends string> = T & {
345
+ __pascal_snake_case__: never;
346
+ };
347
+ /**
348
+ * Type-level utility that identifies the case pattern of a string type.
349
+ * Analyzes the string to determine if it follows a specific case convention
350
+ * such as camelCase, PascalCase, snake_case, etc.
351
+ * @template T - The string type to analyze
352
+ * @returns A string literal type indicating the detected case pattern:
353
+ * - 'snake' for snake_case
354
+ * - 'kebab' for kebab-case
355
+ * - 'flat' for flatcase
356
+ * - 'lower' for lowercase
357
+ * - 'upper' for UPPERCASE
358
+ * - 'train' for Train-Case
359
+ * - 'pascal' for PascalCase
360
+ * - 'camel' for camelCase
361
+ * - 'title' for Title Case
362
+ * - 'mixed' for mixed case patterns
363
+ * - string type for non-literal strings
364
+ * @example
365
+ * type Case1 = IdentifyCase<'foo_bar'> // type Case1 = 'snake'
366
+ * type Case2 = IdentifyCase<'foo-bar'> // type Case2 = 'kebab'
367
+ * type Case3 = IdentifyCase<'fooBar'> // type Case3 = 'camel'
368
+ * type Case4 = IdentifyCase<'FooBar'> // type Case4 = 'pascal'
369
+ * type Case5 = IdentifyCase<'FOO_BAR'> // type Case5 = 'upper'
370
+ */
371
+ type IdentifyCase<T extends string> = IsStringLiteral<T> extends true ? T extends Lowercase<T> ? T extends `${string}_${string}` ? "snake" : T extends `${string}-${string}` ? "kebab" : T extends `${string}${string}` ? "flat" : "lower" : T extends Uppercase<T> ? "upper" : T extends Capitalize<string> ? T extends `${Uppercase<string>}${string}` ? T extends `${string}-${string}` ? "train" : "pascal" : T extends `${Lowercase<string>}${Capitalize<string>}` ? "camel" : T extends `${Capitalize<string>} ${Lowercase<string>}` ? "title" : "mixed" : "mixed" : string;
372
+ /**
373
+ * Type-level utility that splits a string type into an array of substrings based on case boundaries
374
+ * and separator characters. This is particularly useful for breaking down strings in various case
375
+ * formats into their constituent words.
376
+ *
377
+ * The utility handles multiple scenarios:
378
+ * - Case boundaries (e.g., camelCase -> ['camel', 'Case'])
379
+ * - Separator characters (e.g., snake_case -> ['snake', 'case'])
380
+ * - Mixed patterns (e.g., FOO-Bar -> ['FOO', 'Bar'])
381
+ * @template T - The string type to split
382
+ * @template Separator - The separator character(s) to split on (defaults to SplitterCharacter)
383
+ * @template Accumulator - Internal accumulator for building the result array
384
+ * @returns A tuple type containing the split string parts, or string[] for non-literal strings
385
+ * @example
386
+ * type Split1 = SplitByCase<'camelCase'> // type Split1 = ['camel', 'Case']
387
+ * type Split2 = SplitByCase<'foo_bar'> // type Split2 = ['foo', 'bar']
388
+ * type Split3 = SplitByCase<'FOO-Bar'> // type Split3 = ['FOO', 'Bar']
389
+ * type Split4 = SplitByCase<'simpletext'> // type Split4 = ['simpletext']
390
+ */
391
+ type SplitByCase<T, Separator extends string = SplitterCharacter, Accumulator extends unknown[] = []> = string extends Separator ? string[] : T extends `${infer F}${infer R}` ? [LastOfArray<Accumulator>] extends [never] ? SplitByCase<R, Separator, [F]> : LastOfArray<Accumulator> extends string ? R extends "" ? SplitByCase<R, Separator, [...RemoveLastOfArray<Accumulator>, `${LastOfArray<Accumulator>}${F}`]> : SameLetterCase<F, FirstOfString<R>> extends true ? F extends Separator ? FirstOfString<R> extends Separator ? SplitByCase<R, Separator, [...Accumulator, ""]> : IsUpperCase<FirstOfString<R>> extends true ? SplitByCase<RemoveFirstOfString<R>, Separator, [...Accumulator, FirstOfString<R>]> : SplitByCase<R, Separator, [...Accumulator, ""]> : SplitByCase<R, Separator, [...RemoveLastOfArray<Accumulator>, `${LastOfArray<Accumulator>}${F}`]> : IsLowerCase<F> extends true ? SplitByCase<RemoveFirstOfString<R>, Separator, [...RemoveLastOfArray<Accumulator>, `${LastOfArray<Accumulator>}${F}`, FirstOfString<R>]> : SplitByCase<R, Separator, [...Accumulator, F]> : never : Accumulator extends [] ? T extends "" ? [] : string[] : Accumulator;
392
+ export { CaseOptions as C, DotCase as D, FlatCase as F, IdentifyCase as I, KebabCase as K, LocaleOptions as L, NoCase as N, PascalCase as P, SentenceCase as S, TitleCase as T, UpperFirst as U, CamelCase as a, CapitalCase as b, ConstantCase as c, FlipCase as d, LowerFirst as e, PascalSnakeCase as f, PathCase as g, SnakeCase as h, SplitByCase as i, TrainCase as j };