caseparser 5.1.0 → 6.0.1

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/dist/index.cjs CHANGED
@@ -1,1630 +1,116 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/utils.ts
2
+ // src/utils.ts
3
3
  function isString(input) {
4
4
  return typeof input === "string";
5
5
  }
6
6
  function isObject(input) {
7
- return typeof input === "object" && (input === null || input === void 0 ? void 0 : input.constructor) === Object;
7
+ if (typeof input !== "object" || input === null) return false;
8
+ const proto = Object.getPrototypeOf(input);
9
+ return proto !== null && proto.constructor === Object;
8
10
  }
9
11
  function isArray(input) {
10
12
  return Array.isArray(input);
11
13
  }
12
- function Lowercase(str) {
13
- return str.toLowerCase();
14
- }
15
- function Uppercase(str) {
16
- return str.toUpperCase();
17
- }
18
- function Capitalize(str) {
19
- return str.charAt(0).toUpperCase() + str.slice(1);
20
- }
21
- function Uncapitalize(str) {
22
- return str.charAt(0).toLowerCase() + str.slice(1);
23
- }
24
- //#endregion
25
- //#region src/parser/objectParser.ts
26
- function objectParser(input, convertKey) {
14
+ // src/parser/objectParser.ts
15
+ function objectParser(input, context) {
27
16
  const result = {};
28
- for (const property of Object.keys(input)) {
29
- const parsedKey = convertKey(property);
30
- const value = input[property];
31
- let parsedValue;
32
- if (isArray(value)) parsedValue = arrayParser(value, convertKey);
33
- else if (isObject(value)) parsedValue = objectParser(value, convertKey);
34
- else parsedValue = value;
35
- Object.defineProperty(result, parsedKey, {
36
- value: parsedValue,
17
+ const keys = Object.keys(input);
18
+ for (let i = 0; i < keys.length; i++) {
19
+ const key = keys[i];
20
+ const { cache } = context;
21
+ let parsedKey = cache === null || cache === void 0 ? void 0 : cache.get(key);
22
+ if (parsedKey === void 0) {
23
+ parsedKey = context.convertKey(key);
24
+ cache === null || cache === void 0 || cache.set(key, parsedKey);
25
+ }
26
+ let value = input[key];
27
+ if (typeof value === "object" && value !== null) {
28
+ if (Array.isArray(value)) value = arrayParser(value, context);
29
+ else if (isObject(value)) value = objectParser(value, context);
30
+ }
31
+ if (parsedKey === "__proto__") Object.defineProperty(result, parsedKey, {
32
+ value,
37
33
  enumerable: true,
38
34
  writable: true,
39
35
  configurable: true
40
36
  });
37
+ else result[parsedKey] = value;
41
38
  }
42
39
  return result;
43
40
  }
44
- //#endregion
45
- //#region src/parser/arrayParser.ts
46
- function arrayParser(input, convertKey) {
47
- return input.map((item) => {
48
- if (isArray(item)) return arrayParser(item, convertKey);
49
- if (isObject(item)) return objectParser(item, convertKey);
50
- return item;
51
- });
52
- }
53
- //#endregion
54
- //#region src/parser/stringParser.ts
55
- const CamelToDash = (str) => str.replace(/([A-Z])/g, (g) => "-" + g[0].toLowerCase());
56
- const CamelToPascal = (str) => Capitalize(str);
57
- const CamelToSnake = (str) => str.replace(/([A-Z])/g, (g) => "_" + g[0].toLowerCase());
58
- const CamelToUpperDash = (str) => Uppercase(CamelToDash(str));
59
- const CamelToUpperSnake = (str) => Uppercase(CamelToSnake(str));
60
- const CamelToTrain = (str) => DashToTrain(CamelToDash(str));
61
- const CamelToDot = (str) => DashToDot(CamelToDash(str));
62
- const DashToCamel = (str) => str.replace(/(\-\w)/g, (g) => g[1].toUpperCase());
63
- const DashToPascal = (str) => Capitalize(DashToCamel(str));
64
- const DashToSnake = (str) => str.replace(/(\-)/g, "_");
65
- const DashToUpperDash = (str) => Uppercase(str);
66
- const DashToUpperSnake = (str) => Uppercase(DashToSnake(str));
67
- const DashToTrain = (str) => str.split("-").map(Capitalize).join("-");
68
- const DashToDot = (str) => str.replace(/(\-)/g, ".");
69
- const PascalToCamel = (str) => Uncapitalize(str);
70
- const PascalToDash = (str) => CamelToDash(Uncapitalize(str));
71
- const PascalToSnake = (str) => CamelToSnake(Uncapitalize(str));
72
- const PascalToUpperDash = (str) => Uppercase(PascalToDash(str));
73
- const PascalToUpperSnake = (str) => Uppercase(PascalToSnake(str));
74
- const PascalToTrain = (str) => DashToTrain(PascalToDash(str));
75
- const PascalToDot = (str) => DashToDot(PascalToDash(str));
76
- const SnakeToCamel = (str) => str.replace(/(\_\w)/g, (g) => g[1].toUpperCase());
77
- const SnakeToDash = (str) => str.replace(/(\_)/g, "-");
78
- const SnakeToPascal = (str) => Capitalize(SnakeToCamel(str));
79
- const SnakeToUpperDash = (str) => Uppercase(SnakeToDash(str));
80
- const SnakeToTrain = (str) => DashToTrain(SnakeToDash(str));
81
- const SnakeToDot = (str) => DashToDot(SnakeToDash(str));
82
- const SnakeToUpperSnake = (str) => Uppercase(str);
83
- const UpperDashToCamel = (str) => DashToCamel(Lowercase(str));
84
- const UpperDashToDash = (str) => Lowercase(str);
85
- const UpperDashToPascal = (str) => Capitalize(UpperDashToCamel(str));
86
- const UpperDashToSnake = (str) => DashToSnake(UpperDashToDash(str));
87
- const UpperDashToUpperSnake = (str) => Uppercase(UpperDashToSnake(str));
88
- const UpperDashToTrain = (str) => DashToTrain(UpperDashToDash(str));
89
- const UpperDashToDot = (str) => DashToDot(UpperDashToDash(str));
90
- const UpperSnakeToCamel = (str) => SnakeToCamel(Lowercase(str));
91
- const UpperSnakeToDash = (str) => str.replace(/(\_)/g, "-").toLowerCase();
92
- const UpperSnakeToPascal = (str) => SnakeToPascal(Lowercase(str));
93
- const UpperSnakeToSnake = (str) => Lowercase(str);
94
- const UpperSnakeToUpperDash = (str) => Uppercase(UpperSnakeToDash(str));
95
- const UpperSnakeToTrain = (str) => DashToTrain(UpperSnakeToDash(str));
96
- const UpperSnakeToDot = (str) => DashToDot(UpperSnakeToDash(str));
97
- const TrainToCamel = (str) => DashToCamel(TrainToDash(str));
98
- const TrainToDash = (str) => Lowercase(str);
99
- const TrainToDot = (str) => DashToDot(TrainToDash(str));
100
- const TrainToPascal = (str) => DashToPascal(TrainToDash(str));
101
- const TrainToSnake = (str) => DashToSnake(TrainToDash(str));
102
- const TrainToUpperDash = (str) => Uppercase(str);
103
- const TrainToUpperSnake = (str) => DashToUpperSnake(TrainToDash(str));
104
- const DotToCamel = (str) => DashToCamel(DotToDash(str));
105
- const DotToDash = (str) => str.replace(/(\.)/g, "-");
106
- const DotToPascal = (str) => DashToPascal(DotToDash(str));
107
- const DotToSnake = (str) => DashToSnake(DotToDash(str));
108
- const DotToTrain = (str) => DashToTrain(DotToDash(str));
109
- const DotToUpperDash = (str) => Uppercase(DotToDash(str));
110
- const DotToUpperSnake = (str) => DashToUpperSnake(DotToDash(str));
111
- const DashToTitle = (str) => str.split("-").map(Capitalize).join(" ");
112
- const DashToSentence = (str) => Capitalize(str.replace(/(\-)/g, " "));
113
- const CamelToTitle = (str) => DashToTitle(CamelToDash(str));
114
- const CamelToSentence = (str) => DashToSentence(CamelToDash(str));
115
- const PascalToTitle = (str) => DashToTitle(PascalToDash(str));
116
- const PascalToSentence = (str) => DashToSentence(PascalToDash(str));
117
- const SnakeToTitle = (str) => DashToTitle(SnakeToDash(str));
118
- const SnakeToSentence = (str) => DashToSentence(SnakeToDash(str));
119
- const UpperSnakeToTitle = (str) => DashToTitle(UpperSnakeToDash(str));
120
- const UpperSnakeToSentence = (str) => DashToSentence(UpperSnakeToDash(str));
121
- const UpperDashToTitle = (str) => DashToTitle(UpperDashToDash(str));
122
- const UpperDashToSentence = (str) => DashToSentence(UpperDashToDash(str));
123
- const TrainToTitle = (str) => DashToTitle(TrainToDash(str));
124
- const TrainToSentence = (str) => DashToSentence(TrainToDash(str));
125
- const DotToTitle = (str) => DashToTitle(DotToDash(str));
126
- const DotToSentence = (str) => DashToSentence(DotToDash(str));
127
- const TitleToDash = (str) => Lowercase(str).replace(/( )/g, "-");
128
- const TitleToCamel = (str) => DashToCamel(TitleToDash(str));
129
- const TitleToPascal = (str) => DashToPascal(TitleToDash(str));
130
- const TitleToSnake = (str) => DashToSnake(TitleToDash(str));
131
- const TitleToUpperSnake = (str) => DashToUpperSnake(TitleToDash(str));
132
- const TitleToUpperDash = (str) => DashToUpperDash(TitleToDash(str));
133
- const TitleToTrain = (str) => DashToTrain(TitleToDash(str));
134
- const TitleToDot = (str) => DashToDot(TitleToDash(str));
135
- const TitleToSentence = (str) => DashToSentence(TitleToDash(str));
136
- const SentenceToDash = (str) => Lowercase(str).replace(/( )/g, "-");
137
- const SentenceToCamel = (str) => DashToCamel(SentenceToDash(str));
138
- const SentenceToPascal = (str) => DashToPascal(SentenceToDash(str));
139
- const SentenceToSnake = (str) => DashToSnake(SentenceToDash(str));
140
- const SentenceToUpperSnake = (str) => DashToUpperSnake(SentenceToDash(str));
141
- const SentenceToUpperDash = (str) => DashToUpperDash(SentenceToDash(str));
142
- const SentenceToTrain = (str) => DashToTrain(SentenceToDash(str));
143
- const SentenceToDot = (str) => DashToDot(SentenceToDash(str));
144
- const SentenceToTitle = (str) => DashToTitle(SentenceToDash(str));
145
- function parse(input, type) {
146
- return {
147
- CamelToDash,
148
- CamelToPascal,
149
- CamelToSnake,
150
- CamelToUpperDash,
151
- CamelToUpperSnake,
152
- DashToCamel,
153
- DashToSnake,
154
- DashToPascal,
155
- DashToUpperSnake,
156
- DashToUpperDash,
157
- PascalToCamel,
158
- PascalToSnake,
159
- PascalToDash,
160
- PascalToUpperSnake,
161
- PascalToUpperDash,
162
- SnakeToCamel,
163
- SnakeToDash,
164
- SnakeToPascal,
165
- SnakeToUpperSnake,
166
- SnakeToUpperDash,
167
- UpperSnakeToCamel,
168
- UpperSnakeToSnake,
169
- UpperSnakeToDash,
170
- UpperSnakeToPascal,
171
- UpperSnakeToUpperDash,
172
- UpperDashToCamel,
173
- UpperDashToSnake,
174
- UpperDashToDash,
175
- UpperDashToPascal,
176
- UpperDashToUpperSnake,
177
- CamelToTrain,
178
- CamelToDot,
179
- PascalToTrain,
180
- PascalToDot,
181
- SnakeToTrain,
182
- SnakeToDot,
183
- DashToTrain,
184
- DashToDot,
185
- UpperSnakeToTrain,
186
- UpperSnakeToDot,
187
- UpperDashToTrain,
188
- UpperDashToDot,
189
- TrainToCamel,
190
- TrainToPascal,
191
- TrainToSnake,
192
- TrainToDash,
193
- TrainToUpperSnake,
194
- TrainToUpperDash,
195
- TrainToDot,
196
- DotToCamel,
197
- DotToPascal,
198
- DotToSnake,
199
- DotToDash,
200
- DotToUpperSnake,
201
- DotToUpperDash,
202
- DotToTrain,
203
- CamelToTitle,
204
- CamelToSentence,
205
- PascalToTitle,
206
- PascalToSentence,
207
- SnakeToTitle,
208
- SnakeToSentence,
209
- DashToTitle,
210
- DashToSentence,
211
- UpperSnakeToTitle,
212
- UpperSnakeToSentence,
213
- UpperDashToTitle,
214
- UpperDashToSentence,
215
- TrainToTitle,
216
- TrainToSentence,
217
- DotToTitle,
218
- DotToSentence,
219
- TitleToCamel,
220
- TitleToPascal,
221
- TitleToSnake,
222
- TitleToDash,
223
- TitleToUpperSnake,
224
- TitleToUpperDash,
225
- TitleToTrain,
226
- TitleToDot,
227
- TitleToSentence,
228
- SentenceToCamel,
229
- SentenceToPascal,
230
- SentenceToSnake,
231
- SentenceToDash,
232
- SentenceToUpperSnake,
233
- SentenceToUpperDash,
234
- SentenceToTrain,
235
- SentenceToDot,
236
- SentenceToTitle
237
- }[type](input);
41
+ // src/parser/arrayParser.ts
42
+ function arrayParser(input, context) {
43
+ if (!context.cache) context.cache = /* @__PURE__ */ new Map();
44
+ const length = input.length;
45
+ const result = new Array(length);
46
+ for (let i = 0; i < length; i++) {
47
+ const item = input[i];
48
+ if (typeof item === "object" && item !== null) {
49
+ if (Array.isArray(item)) result[i] = arrayParser(item, context);
50
+ else result[i] = isObject(item) ? objectParser(item, context) : item;
51
+ } else result[i] = item;
52
+ }
53
+ return result;
238
54
  }
239
- //#endregion
240
- //#region src/parser/parser.ts
241
- /** Converts a string, or the keys of an object/array (deeply), with `convertKey`. */
242
- function convert(input, convertKey) {
55
+ // src/parser/parser.ts
56
+ /** Converts a string, or the keys of an object/array (deeply), with `convertKey`. Keys in `ignore` are kept as they are. */
57
+ function convert(input, convertKey, ignore) {
243
58
  if (isString(input)) return convertKey(input);
244
- if (isArray(input)) return arrayParser(input, convertKey);
245
- if (isObject(input)) return objectParser(input, convertKey);
246
- }
247
- function converter(input, type) {
248
- return convert(input, (key) => parse(key, type));
249
- }
250
- //#endregion
251
- //#region src/camelCase/camelCase.ts
252
- /**
253
- * Converts a string, or the keys of an object/array (deeply), from camelCase to dash-case.
254
- *
255
- * @example
256
- * ```ts
257
- * camelToDash('helloWorld'); // 'hello-world'
258
- * camelToDash({ firstName: 'John' }); // { 'first-name': 'John' }
259
- * ```
260
- *
261
- * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
262
- * so results differ for keys like `userID` (see the migration notes in the README).
263
- */
264
- function camelToDash(input) {
265
- return converter(input, "CamelToDash");
266
- }
267
- /**
268
- * Converts a string, or the keys of an object/array (deeply), from camelCase to snake_case.
269
- *
270
- * @example
271
- * ```ts
272
- * camelToSnake('helloWorld'); // 'hello_world'
273
- * camelToSnake({ firstName: 'John' }); // { first_name: 'John' }
274
- * ```
275
- *
276
- * @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
277
- * so results differ for keys like `userID` (see the migration notes in the README).
278
- */
279
- function camelToSnake(input) {
280
- return converter(input, "CamelToSnake");
281
- }
282
- /**
283
- * Converts a string, or the keys of an object/array (deeply), from camelCase to PascalCase.
284
- *
285
- * @example
286
- * ```ts
287
- * camelToPascal('helloWorld'); // 'HelloWorld'
288
- * camelToPascal({ firstName: 'John' }); // { FirstName: 'John' }
289
- * ```
290
- *
291
- * @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
292
- * so results differ for keys like `userID` (see the migration notes in the README).
293
- */
294
- function camelToPascal(input) {
295
- return converter(input, "CamelToPascal");
296
- }
297
- /**
298
- * Converts a string, or the keys of an object/array (deeply), from camelCase to UPPER_SNAKE_CASE.
299
- *
300
- * @example
301
- * ```ts
302
- * camelToUpperSnake('helloWorld'); // 'HELLO_WORLD'
303
- * camelToUpperSnake({ firstName: 'John' }); // { FIRST_NAME: 'John' }
304
- * ```
305
- *
306
- * @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
307
- * so results differ for keys like `userID` (see the migration notes in the README).
308
- */
309
- function camelToUpperSnake(input) {
310
- return converter(input, "CamelToUpperSnake");
311
- }
312
- /**
313
- * Converts a string, or the keys of an object/array (deeply), from camelCase to UPPER-DASH-CASE.
314
- *
315
- * @example
316
- * ```ts
317
- * camelToUpperDash('helloWorld'); // 'HELLO-WORLD'
318
- * camelToUpperDash({ firstName: 'John' }); // { 'FIRST-NAME': 'John' }
319
- * ```
320
- *
321
- * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
322
- * so results differ for keys like `userID` (see the migration notes in the README).
323
- */
324
- function camelToUpperDash(input) {
325
- return converter(input, "CamelToUpperDash");
326
- }
327
- /**
328
- * Converts a string, or the keys of an object/array (deeply), from camelCase to Train-Case.
329
- *
330
- * @example
331
- * ```ts
332
- * camelToTrain('helloWorld'); // 'Hello-World'
333
- * camelToTrain({ firstName: 'John' }); // { 'First-Name': 'John' }
334
- * ```
335
- *
336
- * @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
337
- * so results differ for keys like `userID` (see the migration notes in the README).
338
- */
339
- function camelToTrain(input) {
340
- return converter(input, "CamelToTrain");
341
- }
342
- /**
343
- * Converts a string, or the keys of an object/array (deeply), from camelCase to dot.case.
344
- *
345
- * @example
346
- * ```ts
347
- * camelToDot('helloWorld'); // 'hello.world'
348
- * camelToDot({ firstName: 'John' }); // { 'first.name': 'John' }
349
- * ```
350
- *
351
- * @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
352
- * so results differ for keys like `userID` (see the migration notes in the README).
353
- */
354
- function camelToDot(input) {
355
- return converter(input, "CamelToDot");
356
- }
357
- /**
358
- * Converts a string, or the keys of an object/array (deeply), from camelCase to Title Case.
359
- *
360
- * @example
361
- * ```ts
362
- * camelToTitle('helloWorld'); // 'Hello World'
363
- * camelToTitle({ firstName: 'John' }); // { 'First Name': 'John' }
364
- * ```
365
- *
366
- * @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
367
- * so results differ for keys like `userID` (see the migration notes in the README).
368
- */
369
- function camelToTitle(input) {
370
- return converter(input, "CamelToTitle");
371
- }
372
- /**
373
- * Converts a string, or the keys of an object/array (deeply), from camelCase to Sentence case.
374
- *
375
- * @example
376
- * ```ts
377
- * camelToSentence('helloWorld'); // 'Hello world'
378
- * camelToSentence({ firstName: 'John' }); // { 'First name': 'John' }
379
- * ```
380
- *
381
- * @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
382
- * so results differ for keys like `userID` (see the migration notes in the README).
383
- */
384
- function camelToSentence(input) {
385
- return converter(input, "CamelToSentence");
386
- }
387
- //#endregion
388
- //#region src/dashCase/dashCase.ts
389
- /**
390
- * Converts a string, or the keys of an object/array (deeply), from dash-case to snake_case.
391
- *
392
- * @example
393
- * ```ts
394
- * dashToSnake('hello-world'); // 'hello_world'
395
- * dashToSnake({ 'first-name': 'John' }); // { first_name: 'John' }
396
- * ```
397
- *
398
- * @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
399
- * so results differ for keys like `userID` (see the migration notes in the README).
400
- */
401
- function dashToSnake(input) {
402
- return converter(input, "DashToSnake");
403
- }
404
- /**
405
- * Converts a string, or the keys of an object/array (deeply), from dash-case to camelCase.
406
- *
407
- * @example
408
- * ```ts
409
- * dashToCamel('hello-world'); // 'helloWorld'
410
- * dashToCamel({ 'first-name': 'John' }); // { firstName: 'John' }
411
- * ```
412
- *
413
- * @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
414
- * so results differ for keys like `userID` (see the migration notes in the README).
415
- */
416
- function dashToCamel(input) {
417
- return converter(input, "DashToCamel");
418
- }
419
- /**
420
- * Converts a string, or the keys of an object/array (deeply), from dash-case to PascalCase.
421
- *
422
- * @example
423
- * ```ts
424
- * dashToPascal('hello-world'); // 'HelloWorld'
425
- * dashToPascal({ 'first-name': 'John' }); // { FirstName: 'John' }
426
- * ```
427
- *
428
- * @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
429
- * so results differ for keys like `userID` (see the migration notes in the README).
430
- */
431
- function dashToPascal(input) {
432
- return converter(input, "DashToPascal");
433
- }
434
- /**
435
- * Converts a string, or the keys of an object/array (deeply), from dash-case to UPPER_SNAKE_CASE.
436
- *
437
- * @example
438
- * ```ts
439
- * dashToUpperSnake('hello-world'); // 'HELLO_WORLD'
440
- * dashToUpperSnake({ 'first-name': 'John' }); // { FIRST_NAME: 'John' }
441
- * ```
442
- *
443
- * @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
444
- * so results differ for keys like `userID` (see the migration notes in the README).
445
- */
446
- function dashToUpperSnake(input) {
447
- return converter(input, "DashToUpperSnake");
448
- }
449
- /**
450
- * Converts a string, or the keys of an object/array (deeply), from dash-case to UPPER-DASH-CASE.
451
- *
452
- * @example
453
- * ```ts
454
- * dashToUpperDash('hello-world'); // 'HELLO-WORLD'
455
- * dashToUpperDash({ 'first-name': 'John' }); // { 'FIRST-NAME': 'John' }
456
- * ```
457
- *
458
- * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
459
- * so results differ for keys like `userID` (see the migration notes in the README).
460
- */
461
- function dashToUpperDash(input) {
462
- return converter(input, "DashToUpperDash");
463
- }
464
- /**
465
- * Converts a string, or the keys of an object/array (deeply), from dash-case to Train-Case.
466
- *
467
- * @example
468
- * ```ts
469
- * dashToTrain('hello-world'); // 'Hello-World'
470
- * dashToTrain({ 'first-name': 'John' }); // { 'First-Name': 'John' }
471
- * ```
472
- *
473
- * @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
474
- * so results differ for keys like `userID` (see the migration notes in the README).
475
- */
476
- function dashToTrain(input) {
477
- return converter(input, "DashToTrain");
478
- }
479
- /**
480
- * Converts a string, or the keys of an object/array (deeply), from dash-case to dot.case.
481
- *
482
- * @example
483
- * ```ts
484
- * dashToDot('hello-world'); // 'hello.world'
485
- * dashToDot({ 'first-name': 'John' }); // { 'first.name': 'John' }
486
- * ```
487
- *
488
- * @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
489
- * so results differ for keys like `userID` (see the migration notes in the README).
490
- */
491
- function dashToDot(input) {
492
- return converter(input, "DashToDot");
493
- }
494
- /**
495
- * Converts a string, or the keys of an object/array (deeply), from dash-case to Title Case.
496
- *
497
- * @example
498
- * ```ts
499
- * dashToTitle('hello-world'); // 'Hello World'
500
- * dashToTitle({ 'first-name': 'John' }); // { 'First Name': 'John' }
501
- * ```
502
- *
503
- * @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
504
- * so results differ for keys like `userID` (see the migration notes in the README).
505
- */
506
- function dashToTitle(input) {
507
- return converter(input, "DashToTitle");
508
- }
509
- /**
510
- * Converts a string, or the keys of an object/array (deeply), from dash-case to Sentence case.
511
- *
512
- * @example
513
- * ```ts
514
- * dashToSentence('hello-world'); // 'Hello world'
515
- * dashToSentence({ 'first-name': 'John' }); // { 'First name': 'John' }
516
- * ```
517
- *
518
- * @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
519
- * so results differ for keys like `userID` (see the migration notes in the README).
520
- */
521
- function dashToSentence(input) {
522
- return converter(input, "DashToSentence");
523
- }
524
- //#endregion
525
- //#region src/pascalCase/pascalCase.ts
526
- /**
527
- * Converts a string, or the keys of an object/array (deeply), from PascalCase to camelCase.
528
- *
529
- * @example
530
- * ```ts
531
- * pascalToCamel('HelloWorld'); // 'helloWorld'
532
- * pascalToCamel({ FirstName: 'John' }); // { firstName: 'John' }
533
- * ```
534
- *
535
- * @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
536
- * so results differ for keys like `userID` (see the migration notes in the README).
537
- */
538
- function pascalToCamel(input) {
539
- return converter(input, "PascalToCamel");
540
- }
541
- /**
542
- * Converts a string, or the keys of an object/array (deeply), from PascalCase to snake_case.
543
- *
544
- * @example
545
- * ```ts
546
- * pascalToSnake('HelloWorld'); // 'hello_world'
547
- * pascalToSnake({ FirstName: 'John' }); // { first_name: 'John' }
548
- * ```
549
- *
550
- * @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
551
- * so results differ for keys like `userID` (see the migration notes in the README).
552
- */
553
- function pascalToSnake(input) {
554
- return converter(input, "PascalToSnake");
555
- }
556
- /**
557
- * Converts a string, or the keys of an object/array (deeply), from PascalCase to dash-case.
558
- *
559
- * @example
560
- * ```ts
561
- * pascalToDash('HelloWorld'); // 'hello-world'
562
- * pascalToDash({ FirstName: 'John' }); // { 'first-name': 'John' }
563
- * ```
564
- *
565
- * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
566
- * so results differ for keys like `userID` (see the migration notes in the README).
567
- */
568
- function pascalToDash(input) {
569
- return converter(input, "PascalToDash");
570
- }
571
- /**
572
- * Converts a string, or the keys of an object/array (deeply), from PascalCase to UPPER_SNAKE_CASE.
573
- *
574
- * @example
575
- * ```ts
576
- * pascalToUpperSnake('HelloWorld'); // 'HELLO_WORLD'
577
- * pascalToUpperSnake({ FirstName: 'John' }); // { FIRST_NAME: 'John' }
578
- * ```
579
- *
580
- * @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
581
- * so results differ for keys like `userID` (see the migration notes in the README).
582
- */
583
- function pascalToUpperSnake(input) {
584
- return converter(input, "PascalToUpperSnake");
585
- }
586
- /**
587
- * Converts a string, or the keys of an object/array (deeply), from PascalCase to UPPER-DASH-CASE.
588
- *
589
- * @example
590
- * ```ts
591
- * pascalToUpperDash('HelloWorld'); // 'HELLO-WORLD'
592
- * pascalToUpperDash({ FirstName: 'John' }); // { 'FIRST-NAME': 'John' }
593
- * ```
594
- *
595
- * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
596
- * so results differ for keys like `userID` (see the migration notes in the README).
597
- */
598
- function pascalToUpperDash(input) {
599
- return converter(input, "PascalToUpperDash");
600
- }
601
- /**
602
- * Converts a string, or the keys of an object/array (deeply), from PascalCase to Train-Case.
603
- *
604
- * @example
605
- * ```ts
606
- * pascalToTrain('HelloWorld'); // 'Hello-World'
607
- * pascalToTrain({ FirstName: 'John' }); // { 'First-Name': 'John' }
608
- * ```
609
- *
610
- * @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
611
- * so results differ for keys like `userID` (see the migration notes in the README).
612
- */
613
- function pascalToTrain(input) {
614
- return converter(input, "PascalToTrain");
615
- }
616
- /**
617
- * Converts a string, or the keys of an object/array (deeply), from PascalCase to dot.case.
618
- *
619
- * @example
620
- * ```ts
621
- * pascalToDot('HelloWorld'); // 'hello.world'
622
- * pascalToDot({ FirstName: 'John' }); // { 'first.name': 'John' }
623
- * ```
624
- *
625
- * @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
626
- * so results differ for keys like `userID` (see the migration notes in the README).
627
- */
628
- function pascalToDot(input) {
629
- return converter(input, "PascalToDot");
630
- }
631
- /**
632
- * Converts a string, or the keys of an object/array (deeply), from PascalCase to Title Case.
633
- *
634
- * @example
635
- * ```ts
636
- * pascalToTitle('HelloWorld'); // 'Hello World'
637
- * pascalToTitle({ FirstName: 'John' }); // { 'First Name': 'John' }
638
- * ```
639
- *
640
- * @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
641
- * so results differ for keys like `userID` (see the migration notes in the README).
642
- */
643
- function pascalToTitle(input) {
644
- return converter(input, "PascalToTitle");
645
- }
646
- /**
647
- * Converts a string, or the keys of an object/array (deeply), from PascalCase to Sentence case.
648
- *
649
- * @example
650
- * ```ts
651
- * pascalToSentence('HelloWorld'); // 'Hello world'
652
- * pascalToSentence({ FirstName: 'John' }); // { 'First name': 'John' }
653
- * ```
654
- *
655
- * @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
656
- * so results differ for keys like `userID` (see the migration notes in the README).
657
- */
658
- function pascalToSentence(input) {
659
- return converter(input, "PascalToSentence");
660
- }
661
- //#endregion
662
- //#region src/snakeCase/snakeCase.ts
663
- /**
664
- * Converts a string, or the keys of an object/array (deeply), from snake_case to camelCase.
665
- *
666
- * @example
667
- * ```ts
668
- * snakeToCamel('hello_world'); // 'helloWorld'
669
- * snakeToCamel({ first_name: 'John' }); // { firstName: 'John' }
670
- * ```
671
- *
672
- * @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
673
- * so results differ for keys like `userID` (see the migration notes in the README).
674
- */
675
- function snakeToCamel(input) {
676
- return converter(input, "SnakeToCamel");
677
- }
678
- /**
679
- * Converts a string, or the keys of an object/array (deeply), from snake_case to dash-case.
680
- *
681
- * @example
682
- * ```ts
683
- * snakeToDash('hello_world'); // 'hello-world'
684
- * snakeToDash({ first_name: 'John' }); // { 'first-name': 'John' }
685
- * ```
686
- *
687
- * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
688
- * so results differ for keys like `userID` (see the migration notes in the README).
689
- */
690
- function snakeToDash(input) {
691
- return converter(input, "SnakeToDash");
692
- }
693
- /**
694
- * Converts a string, or the keys of an object/array (deeply), from snake_case to PascalCase.
695
- *
696
- * @example
697
- * ```ts
698
- * snakeToPascal('hello_world'); // 'HelloWorld'
699
- * snakeToPascal({ first_name: 'John' }); // { FirstName: 'John' }
700
- * ```
701
- *
702
- * @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
703
- * so results differ for keys like `userID` (see the migration notes in the README).
704
- */
705
- function snakeToPascal(input) {
706
- return converter(input, "SnakeToPascal");
707
- }
708
- /**
709
- * Converts a string, or the keys of an object/array (deeply), from snake_case to UPPER_SNAKE_CASE.
710
- *
711
- * @example
712
- * ```ts
713
- * snakeToUpperSnake('hello_world'); // 'HELLO_WORLD'
714
- * snakeToUpperSnake({ first_name: 'John' }); // { FIRST_NAME: 'John' }
715
- * ```
716
- *
717
- * @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
718
- * so results differ for keys like `userID` (see the migration notes in the README).
719
- */
720
- function snakeToUpperSnake(input) {
721
- return converter(input, "SnakeToUpperSnake");
722
- }
723
- /**
724
- * Converts a string, or the keys of an object/array (deeply), from snake_case to UPPER-DASH-CASE.
725
- *
726
- * @example
727
- * ```ts
728
- * snakeToUpperDash('hello_world'); // 'HELLO-WORLD'
729
- * snakeToUpperDash({ first_name: 'John' }); // { 'FIRST-NAME': 'John' }
730
- * ```
731
- *
732
- * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
733
- * so results differ for keys like `userID` (see the migration notes in the README).
734
- */
735
- function snakeToUpperDash(input) {
736
- return converter(input, "SnakeToUpperDash");
737
- }
738
- /**
739
- * Converts a string, or the keys of an object/array (deeply), from snake_case to Train-Case.
740
- *
741
- * @example
742
- * ```ts
743
- * snakeToTrain('hello_world'); // 'Hello-World'
744
- * snakeToTrain({ first_name: 'John' }); // { 'First-Name': 'John' }
745
- * ```
746
- *
747
- * @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
748
- * so results differ for keys like `userID` (see the migration notes in the README).
749
- */
750
- function snakeToTrain(input) {
751
- return converter(input, "SnakeToTrain");
752
- }
753
- /**
754
- * Converts a string, or the keys of an object/array (deeply), from snake_case to dot.case.
755
- *
756
- * @example
757
- * ```ts
758
- * snakeToDot('hello_world'); // 'hello.world'
759
- * snakeToDot({ first_name: 'John' }); // { 'first.name': 'John' }
760
- * ```
761
- *
762
- * @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
763
- * so results differ for keys like `userID` (see the migration notes in the README).
764
- */
765
- function snakeToDot(input) {
766
- return converter(input, "SnakeToDot");
767
- }
768
- /**
769
- * Converts a string, or the keys of an object/array (deeply), from snake_case to Title Case.
770
- *
771
- * @example
772
- * ```ts
773
- * snakeToTitle('hello_world'); // 'Hello World'
774
- * snakeToTitle({ first_name: 'John' }); // { 'First Name': 'John' }
775
- * ```
776
- *
777
- * @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
778
- * so results differ for keys like `userID` (see the migration notes in the README).
779
- */
780
- function snakeToTitle(input) {
781
- return converter(input, "SnakeToTitle");
782
- }
783
- /**
784
- * Converts a string, or the keys of an object/array (deeply), from snake_case to Sentence case.
785
- *
786
- * @example
787
- * ```ts
788
- * snakeToSentence('hello_world'); // 'Hello world'
789
- * snakeToSentence({ first_name: 'John' }); // { 'First name': 'John' }
790
- * ```
791
- *
792
- * @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
793
- * so results differ for keys like `userID` (see the migration notes in the README).
794
- */
795
- function snakeToSentence(input) {
796
- return converter(input, "SnakeToSentence");
797
- }
798
- //#endregion
799
- //#region src/trainCase/trainCase.ts
800
- /**
801
- * Converts a string, or the keys of an object/array (deeply), from Train-Case to camelCase.
802
- *
803
- * @example
804
- * ```ts
805
- * trainToCamel('Hello-World'); // 'helloWorld'
806
- * trainToCamel({ 'First-Name': 'John' }); // { firstName: 'John' }
807
- * ```
808
- *
809
- * @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
810
- * so results differ for keys like `userID` (see the migration notes in the README).
811
- */
812
- function trainToCamel(input) {
813
- return converter(input, "TrainToCamel");
814
- }
815
- /**
816
- * Converts a string, or the keys of an object/array (deeply), from Train-Case to PascalCase.
817
- *
818
- * @example
819
- * ```ts
820
- * trainToPascal('Hello-World'); // 'HelloWorld'
821
- * trainToPascal({ 'First-Name': 'John' }); // { FirstName: 'John' }
822
- * ```
823
- *
824
- * @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
825
- * so results differ for keys like `userID` (see the migration notes in the README).
826
- */
827
- function trainToPascal(input) {
828
- return converter(input, "TrainToPascal");
829
- }
830
- /**
831
- * Converts a string, or the keys of an object/array (deeply), from Train-Case to snake_case.
832
- *
833
- * @example
834
- * ```ts
835
- * trainToSnake('Hello-World'); // 'hello_world'
836
- * trainToSnake({ 'First-Name': 'John' }); // { first_name: 'John' }
837
- * ```
838
- *
839
- * @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
840
- * so results differ for keys like `userID` (see the migration notes in the README).
841
- */
842
- function trainToSnake(input) {
843
- return converter(input, "TrainToSnake");
844
- }
845
- /**
846
- * Converts a string, or the keys of an object/array (deeply), from Train-Case to dash-case.
847
- *
848
- * @example
849
- * ```ts
850
- * trainToDash('Hello-World'); // 'hello-world'
851
- * trainToDash({ 'First-Name': 'John' }); // { 'first-name': 'John' }
852
- * ```
853
- *
854
- * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
855
- * so results differ for keys like `userID` (see the migration notes in the README).
856
- */
857
- function trainToDash(input) {
858
- return converter(input, "TrainToDash");
859
- }
860
- /**
861
- * Converts a string, or the keys of an object/array (deeply), from Train-Case to UPPER_SNAKE_CASE.
862
- *
863
- * @example
864
- * ```ts
865
- * trainToUpperSnake('Hello-World'); // 'HELLO_WORLD'
866
- * trainToUpperSnake({ 'First-Name': 'John' }); // { FIRST_NAME: 'John' }
867
- * ```
868
- *
869
- * @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
870
- * so results differ for keys like `userID` (see the migration notes in the README).
871
- */
872
- function trainToUpperSnake(input) {
873
- return converter(input, "TrainToUpperSnake");
874
- }
875
- /**
876
- * Converts a string, or the keys of an object/array (deeply), from Train-Case to UPPER-DASH-CASE.
877
- *
878
- * @example
879
- * ```ts
880
- * trainToUpperDash('Hello-World'); // 'HELLO-WORLD'
881
- * trainToUpperDash({ 'First-Name': 'John' }); // { 'FIRST-NAME': 'John' }
882
- * ```
883
- *
884
- * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
885
- * so results differ for keys like `userID` (see the migration notes in the README).
886
- */
887
- function trainToUpperDash(input) {
888
- return converter(input, "TrainToUpperDash");
889
- }
890
- /**
891
- * Converts a string, or the keys of an object/array (deeply), from Train-Case to dot.case.
892
- *
893
- * @example
894
- * ```ts
895
- * trainToDot('Hello-World'); // 'hello.world'
896
- * trainToDot({ 'First-Name': 'John' }); // { 'first.name': 'John' }
897
- * ```
898
- *
899
- * @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
900
- * so results differ for keys like `userID` (see the migration notes in the README).
901
- */
902
- function trainToDot(input) {
903
- return converter(input, "TrainToDot");
904
- }
905
- /**
906
- * Converts a string, or the keys of an object/array (deeply), from Train-Case to Title Case.
907
- *
908
- * @example
909
- * ```ts
910
- * trainToTitle('Hello-World'); // 'Hello World'
911
- * trainToTitle({ 'First-Name': 'John' }); // { 'First Name': 'John' }
912
- * ```
913
- *
914
- * @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
915
- * so results differ for keys like `userID` (see the migration notes in the README).
916
- */
917
- function trainToTitle(input) {
918
- return converter(input, "TrainToTitle");
919
- }
920
- /**
921
- * Converts a string, or the keys of an object/array (deeply), from Train-Case to Sentence case.
922
- *
923
- * @example
924
- * ```ts
925
- * trainToSentence('Hello-World'); // 'Hello world'
926
- * trainToSentence({ 'First-Name': 'John' }); // { 'First name': 'John' }
927
- * ```
928
- *
929
- * @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
930
- * so results differ for keys like `userID` (see the migration notes in the README).
931
- */
932
- function trainToSentence(input) {
933
- return converter(input, "TrainToSentence");
934
- }
935
- //#endregion
936
- //#region src/dotCase/dotCase.ts
937
- /**
938
- * Converts a string, or the keys of an object/array (deeply), from dot.case to camelCase.
939
- *
940
- * @example
941
- * ```ts
942
- * dotToCamel('hello.world'); // 'helloWorld'
943
- * dotToCamel({ 'first.name': 'John' }); // { firstName: 'John' }
944
- * ```
945
- *
946
- * @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
947
- * so results differ for keys like `userID` (see the migration notes in the README).
948
- */
949
- function dotToCamel(input) {
950
- return converter(input, "DotToCamel");
951
- }
952
- /**
953
- * Converts a string, or the keys of an object/array (deeply), from dot.case to PascalCase.
954
- *
955
- * @example
956
- * ```ts
957
- * dotToPascal('hello.world'); // 'HelloWorld'
958
- * dotToPascal({ 'first.name': 'John' }); // { FirstName: 'John' }
959
- * ```
960
- *
961
- * @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
962
- * so results differ for keys like `userID` (see the migration notes in the README).
963
- */
964
- function dotToPascal(input) {
965
- return converter(input, "DotToPascal");
966
- }
967
- /**
968
- * Converts a string, or the keys of an object/array (deeply), from dot.case to snake_case.
969
- *
970
- * @example
971
- * ```ts
972
- * dotToSnake('hello.world'); // 'hello_world'
973
- * dotToSnake({ 'first.name': 'John' }); // { first_name: 'John' }
974
- * ```
975
- *
976
- * @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
977
- * so results differ for keys like `userID` (see the migration notes in the README).
978
- */
979
- function dotToSnake(input) {
980
- return converter(input, "DotToSnake");
981
- }
982
- /**
983
- * Converts a string, or the keys of an object/array (deeply), from dot.case to dash-case.
984
- *
985
- * @example
986
- * ```ts
987
- * dotToDash('hello.world'); // 'hello-world'
988
- * dotToDash({ 'first.name': 'John' }); // { 'first-name': 'John' }
989
- * ```
990
- *
991
- * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
992
- * so results differ for keys like `userID` (see the migration notes in the README).
993
- */
994
- function dotToDash(input) {
995
- return converter(input, "DotToDash");
996
- }
997
- /**
998
- * Converts a string, or the keys of an object/array (deeply), from dot.case to UPPER_SNAKE_CASE.
999
- *
1000
- * @example
1001
- * ```ts
1002
- * dotToUpperSnake('hello.world'); // 'HELLO_WORLD'
1003
- * dotToUpperSnake({ 'first.name': 'John' }); // { FIRST_NAME: 'John' }
1004
- * ```
1005
- *
1006
- * @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
1007
- * so results differ for keys like `userID` (see the migration notes in the README).
1008
- */
1009
- function dotToUpperSnake(input) {
1010
- return converter(input, "DotToUpperSnake");
1011
- }
1012
- /**
1013
- * Converts a string, or the keys of an object/array (deeply), from dot.case to UPPER-DASH-CASE.
1014
- *
1015
- * @example
1016
- * ```ts
1017
- * dotToUpperDash('hello.world'); // 'HELLO-WORLD'
1018
- * dotToUpperDash({ 'first.name': 'John' }); // { 'FIRST-NAME': 'John' }
1019
- * ```
1020
- *
1021
- * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
1022
- * so results differ for keys like `userID` (see the migration notes in the README).
1023
- */
1024
- function dotToUpperDash(input) {
1025
- return converter(input, "DotToUpperDash");
1026
- }
1027
- /**
1028
- * Converts a string, or the keys of an object/array (deeply), from dot.case to Train-Case.
1029
- *
1030
- * @example
1031
- * ```ts
1032
- * dotToTrain('hello.world'); // 'Hello-World'
1033
- * dotToTrain({ 'first.name': 'John' }); // { 'First-Name': 'John' }
1034
- * ```
1035
- *
1036
- * @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
1037
- * so results differ for keys like `userID` (see the migration notes in the README).
1038
- */
1039
- function dotToTrain(input) {
1040
- return converter(input, "DotToTrain");
1041
- }
1042
- /**
1043
- * Converts a string, or the keys of an object/array (deeply), from dot.case to Title Case.
1044
- *
1045
- * @example
1046
- * ```ts
1047
- * dotToTitle('hello.world'); // 'Hello World'
1048
- * dotToTitle({ 'first.name': 'John' }); // { 'First Name': 'John' }
1049
- * ```
1050
- *
1051
- * @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
1052
- * so results differ for keys like `userID` (see the migration notes in the README).
1053
- */
1054
- function dotToTitle(input) {
1055
- return converter(input, "DotToTitle");
1056
- }
1057
- /**
1058
- * Converts a string, or the keys of an object/array (deeply), from dot.case to Sentence case.
1059
- *
1060
- * @example
1061
- * ```ts
1062
- * dotToSentence('hello.world'); // 'Hello world'
1063
- * dotToSentence({ 'first.name': 'John' }); // { 'First name': 'John' }
1064
- * ```
1065
- *
1066
- * @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
1067
- * so results differ for keys like `userID` (see the migration notes in the README).
1068
- */
1069
- function dotToSentence(input) {
1070
- return converter(input, "DotToSentence");
1071
- }
1072
- //#endregion
1073
- //#region src/titleCase/titleCase.ts
1074
- /**
1075
- * Converts a string, or the keys of an object/array (deeply), from Title Case to camelCase.
1076
- *
1077
- * @example
1078
- * ```ts
1079
- * titleToCamel('Hello World'); // 'helloWorld'
1080
- * titleToCamel({ 'First Name': 'John' }); // { firstName: 'John' }
1081
- * ```
1082
- *
1083
- * @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
1084
- * so results differ for keys like `userID` (see the migration notes in the README).
1085
- */
1086
- function titleToCamel(input) {
1087
- return converter(input, "TitleToCamel");
1088
- }
1089
- /**
1090
- * Converts a string, or the keys of an object/array (deeply), from Title Case to PascalCase.
1091
- *
1092
- * @example
1093
- * ```ts
1094
- * titleToPascal('Hello World'); // 'HelloWorld'
1095
- * titleToPascal({ 'First Name': 'John' }); // { FirstName: 'John' }
1096
- * ```
1097
- *
1098
- * @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
1099
- * so results differ for keys like `userID` (see the migration notes in the README).
1100
- */
1101
- function titleToPascal(input) {
1102
- return converter(input, "TitleToPascal");
1103
- }
1104
- /**
1105
- * Converts a string, or the keys of an object/array (deeply), from Title Case to snake_case.
1106
- *
1107
- * @example
1108
- * ```ts
1109
- * titleToSnake('Hello World'); // 'hello_world'
1110
- * titleToSnake({ 'First Name': 'John' }); // { first_name: 'John' }
1111
- * ```
1112
- *
1113
- * @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
1114
- * so results differ for keys like `userID` (see the migration notes in the README).
1115
- */
1116
- function titleToSnake(input) {
1117
- return converter(input, "TitleToSnake");
1118
- }
1119
- /**
1120
- * Converts a string, or the keys of an object/array (deeply), from Title Case to dash-case.
1121
- *
1122
- * @example
1123
- * ```ts
1124
- * titleToDash('Hello World'); // 'hello-world'
1125
- * titleToDash({ 'First Name': 'John' }); // { 'first-name': 'John' }
1126
- * ```
1127
- *
1128
- * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
1129
- * so results differ for keys like `userID` (see the migration notes in the README).
1130
- */
1131
- function titleToDash(input) {
1132
- return converter(input, "TitleToDash");
1133
- }
1134
- /**
1135
- * Converts a string, or the keys of an object/array (deeply), from Title Case to UPPER_SNAKE_CASE.
1136
- *
1137
- * @example
1138
- * ```ts
1139
- * titleToUpperSnake('Hello World'); // 'HELLO_WORLD'
1140
- * titleToUpperSnake({ 'First Name': 'John' }); // { FIRST_NAME: 'John' }
1141
- * ```
1142
- *
1143
- * @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
1144
- * so results differ for keys like `userID` (see the migration notes in the README).
1145
- */
1146
- function titleToUpperSnake(input) {
1147
- return converter(input, "TitleToUpperSnake");
1148
- }
1149
- /**
1150
- * Converts a string, or the keys of an object/array (deeply), from Title Case to UPPER-DASH-CASE.
1151
- *
1152
- * @example
1153
- * ```ts
1154
- * titleToUpperDash('Hello World'); // 'HELLO-WORLD'
1155
- * titleToUpperDash({ 'First Name': 'John' }); // { 'FIRST-NAME': 'John' }
1156
- * ```
1157
- *
1158
- * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
1159
- * so results differ for keys like `userID` (see the migration notes in the README).
1160
- */
1161
- function titleToUpperDash(input) {
1162
- return converter(input, "TitleToUpperDash");
1163
- }
1164
- /**
1165
- * Converts a string, or the keys of an object/array (deeply), from Title Case to Train-Case.
1166
- *
1167
- * @example
1168
- * ```ts
1169
- * titleToTrain('Hello World'); // 'Hello-World'
1170
- * titleToTrain({ 'First Name': 'John' }); // { 'First-Name': 'John' }
1171
- * ```
1172
- *
1173
- * @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
1174
- * so results differ for keys like `userID` (see the migration notes in the README).
1175
- */
1176
- function titleToTrain(input) {
1177
- return converter(input, "TitleToTrain");
1178
- }
1179
- /**
1180
- * Converts a string, or the keys of an object/array (deeply), from Title Case to dot.case.
1181
- *
1182
- * @example
1183
- * ```ts
1184
- * titleToDot('Hello World'); // 'hello.world'
1185
- * titleToDot({ 'First Name': 'John' }); // { 'first.name': 'John' }
1186
- * ```
1187
- *
1188
- * @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
1189
- * so results differ for keys like `userID` (see the migration notes in the README).
1190
- */
1191
- function titleToDot(input) {
1192
- return converter(input, "TitleToDot");
1193
- }
1194
- /**
1195
- * Converts a string, or the keys of an object/array (deeply), from Title Case to Sentence case.
1196
- *
1197
- * @example
1198
- * ```ts
1199
- * titleToSentence('Hello World'); // 'Hello world'
1200
- * titleToSentence({ 'First Name': 'John' }); // { 'First name': 'John' }
1201
- * ```
1202
- *
1203
- * @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
1204
- * so results differ for keys like `userID` (see the migration notes in the README).
1205
- */
1206
- function titleToSentence(input) {
1207
- return converter(input, "TitleToSentence");
1208
- }
1209
- //#endregion
1210
- //#region src/sentenceCase/sentenceCase.ts
1211
- /**
1212
- * Converts a string, or the keys of an object/array (deeply), from Sentence case to camelCase.
1213
- *
1214
- * @example
1215
- * ```ts
1216
- * sentenceToCamel('Hello world'); // 'helloWorld'
1217
- * sentenceToCamel({ 'First name': 'John' }); // { firstName: 'John' }
1218
- * ```
1219
- *
1220
- * @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
1221
- * so results differ for keys like `userID` (see the migration notes in the README).
1222
- */
1223
- function sentenceToCamel(input) {
1224
- return converter(input, "SentenceToCamel");
1225
- }
1226
- /**
1227
- * Converts a string, or the keys of an object/array (deeply), from Sentence case to PascalCase.
1228
- *
1229
- * @example
1230
- * ```ts
1231
- * sentenceToPascal('Hello world'); // 'HelloWorld'
1232
- * sentenceToPascal({ 'First name': 'John' }); // { FirstName: 'John' }
1233
- * ```
1234
- *
1235
- * @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
1236
- * so results differ for keys like `userID` (see the migration notes in the README).
1237
- */
1238
- function sentenceToPascal(input) {
1239
- return converter(input, "SentenceToPascal");
1240
- }
1241
- /**
1242
- * Converts a string, or the keys of an object/array (deeply), from Sentence case to snake_case.
1243
- *
1244
- * @example
1245
- * ```ts
1246
- * sentenceToSnake('Hello world'); // 'hello_world'
1247
- * sentenceToSnake({ 'First name': 'John' }); // { first_name: 'John' }
1248
- * ```
1249
- *
1250
- * @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
1251
- * so results differ for keys like `userID` (see the migration notes in the README).
1252
- */
1253
- function sentenceToSnake(input) {
1254
- return converter(input, "SentenceToSnake");
1255
- }
1256
- /**
1257
- * Converts a string, or the keys of an object/array (deeply), from Sentence case to dash-case.
1258
- *
1259
- * @example
1260
- * ```ts
1261
- * sentenceToDash('Hello world'); // 'hello-world'
1262
- * sentenceToDash({ 'First name': 'John' }); // { 'first-name': 'John' }
1263
- * ```
1264
- *
1265
- * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
1266
- * so results differ for keys like `userID` (see the migration notes in the README).
1267
- */
1268
- function sentenceToDash(input) {
1269
- return converter(input, "SentenceToDash");
1270
- }
1271
- /**
1272
- * Converts a string, or the keys of an object/array (deeply), from Sentence case to UPPER_SNAKE_CASE.
1273
- *
1274
- * @example
1275
- * ```ts
1276
- * sentenceToUpperSnake('Hello world'); // 'HELLO_WORLD'
1277
- * sentenceToUpperSnake({ 'First name': 'John' }); // { FIRST_NAME: 'John' }
1278
- * ```
1279
- *
1280
- * @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
1281
- * so results differ for keys like `userID` (see the migration notes in the README).
1282
- */
1283
- function sentenceToUpperSnake(input) {
1284
- return converter(input, "SentenceToUpperSnake");
1285
- }
1286
- /**
1287
- * Converts a string, or the keys of an object/array (deeply), from Sentence case to UPPER-DASH-CASE.
1288
- *
1289
- * @example
1290
- * ```ts
1291
- * sentenceToUpperDash('Hello world'); // 'HELLO-WORLD'
1292
- * sentenceToUpperDash({ 'First name': 'John' }); // { 'FIRST-NAME': 'John' }
1293
- * ```
1294
- *
1295
- * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
1296
- * so results differ for keys like `userID` (see the migration notes in the README).
1297
- */
1298
- function sentenceToUpperDash(input) {
1299
- return converter(input, "SentenceToUpperDash");
1300
- }
1301
- /**
1302
- * Converts a string, or the keys of an object/array (deeply), from Sentence case to Train-Case.
1303
- *
1304
- * @example
1305
- * ```ts
1306
- * sentenceToTrain('Hello world'); // 'Hello-World'
1307
- * sentenceToTrain({ 'First name': 'John' }); // { 'First-Name': 'John' }
1308
- * ```
1309
- *
1310
- * @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
1311
- * so results differ for keys like `userID` (see the migration notes in the README).
1312
- */
1313
- function sentenceToTrain(input) {
1314
- return converter(input, "SentenceToTrain");
1315
- }
1316
- /**
1317
- * Converts a string, or the keys of an object/array (deeply), from Sentence case to dot.case.
1318
- *
1319
- * @example
1320
- * ```ts
1321
- * sentenceToDot('Hello world'); // 'hello.world'
1322
- * sentenceToDot({ 'First name': 'John' }); // { 'first.name': 'John' }
1323
- * ```
1324
- *
1325
- * @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
1326
- * so results differ for keys like `userID` (see the migration notes in the README).
1327
- */
1328
- function sentenceToDot(input) {
1329
- return converter(input, "SentenceToDot");
1330
- }
1331
- /**
1332
- * Converts a string, or the keys of an object/array (deeply), from Sentence case to Title Case.
1333
- *
1334
- * @example
1335
- * ```ts
1336
- * sentenceToTitle('Hello world'); // 'Hello World'
1337
- * sentenceToTitle({ 'First name': 'John' }); // { 'First Name': 'John' }
1338
- * ```
1339
- *
1340
- * @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
1341
- * so results differ for keys like `userID` (see the migration notes in the README).
1342
- */
1343
- function sentenceToTitle(input) {
1344
- return converter(input, "SentenceToTitle");
1345
- }
1346
- //#endregion
1347
- //#region src/upperDashCase/upperDashCase.ts
1348
- /**
1349
- * Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to camelCase.
1350
- *
1351
- * @example
1352
- * ```ts
1353
- * upperDashToCamel('HELLO-WORLD'); // 'helloWorld'
1354
- * upperDashToCamel({ 'FIRST-NAME': 'John' }); // { firstName: 'John' }
1355
- * ```
1356
- *
1357
- * @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
1358
- * so results differ for keys like `userID` (see the migration notes in the README).
1359
- */
1360
- function upperDashToCamel(input) {
1361
- return converter(input, "UpperDashToCamel");
1362
- }
1363
- /**
1364
- * Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to snake_case.
1365
- *
1366
- * @example
1367
- * ```ts
1368
- * upperDashToSnake('HELLO-WORLD'); // 'hello_world'
1369
- * upperDashToSnake({ 'FIRST-NAME': 'John' }); // { first_name: 'John' }
1370
- * ```
1371
- *
1372
- * @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
1373
- * so results differ for keys like `userID` (see the migration notes in the README).
1374
- */
1375
- function upperDashToSnake(input) {
1376
- return converter(input, "UpperDashToSnake");
1377
- }
1378
- /**
1379
- * Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to dash-case.
1380
- *
1381
- * @example
1382
- * ```ts
1383
- * upperDashToDash('HELLO-WORLD'); // 'hello-world'
1384
- * upperDashToDash({ 'FIRST-NAME': 'John' }); // { 'first-name': 'John' }
1385
- * ```
1386
- *
1387
- * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
1388
- * so results differ for keys like `userID` (see the migration notes in the README).
1389
- */
1390
- function upperDashToDash(input) {
1391
- return converter(input, "UpperDashToDash");
1392
- }
1393
- /**
1394
- * Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to PascalCase.
1395
- *
1396
- * @example
1397
- * ```ts
1398
- * upperDashToPascal('HELLO-WORLD'); // 'HelloWorld'
1399
- * upperDashToPascal({ 'FIRST-NAME': 'John' }); // { FirstName: 'John' }
1400
- * ```
1401
- *
1402
- * @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
1403
- * so results differ for keys like `userID` (see the migration notes in the README).
1404
- */
1405
- function upperDashToPascal(input) {
1406
- return converter(input, "UpperDashToPascal");
1407
- }
1408
- /**
1409
- * Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to UPPER_SNAKE_CASE.
1410
- *
1411
- * @example
1412
- * ```ts
1413
- * upperDashToUpperSnake('HELLO-WORLD'); // 'HELLO_WORLD'
1414
- * upperDashToUpperSnake({ 'FIRST-NAME': 'John' }); // { FIRST_NAME: 'John' }
1415
- * ```
1416
- *
1417
- * @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
1418
- * so results differ for keys like `userID` (see the migration notes in the README).
1419
- */
1420
- function upperDashToUpperSnake(input) {
1421
- return converter(input, "UpperDashToUpperSnake");
1422
- }
1423
- /**
1424
- * Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to Train-Case.
1425
- *
1426
- * @example
1427
- * ```ts
1428
- * upperDashToTrain('HELLO-WORLD'); // 'Hello-World'
1429
- * upperDashToTrain({ 'FIRST-NAME': 'John' }); // { 'First-Name': 'John' }
1430
- * ```
1431
- *
1432
- * @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
1433
- * so results differ for keys like `userID` (see the migration notes in the README).
1434
- */
1435
- function upperDashToTrain(input) {
1436
- return converter(input, "UpperDashToTrain");
1437
- }
1438
- /**
1439
- * Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to dot.case.
1440
- *
1441
- * @example
1442
- * ```ts
1443
- * upperDashToDot('HELLO-WORLD'); // 'hello.world'
1444
- * upperDashToDot({ 'FIRST-NAME': 'John' }); // { 'first.name': 'John' }
1445
- * ```
1446
- *
1447
- * @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
1448
- * so results differ for keys like `userID` (see the migration notes in the README).
1449
- */
1450
- function upperDashToDot(input) {
1451
- return converter(input, "UpperDashToDot");
1452
- }
1453
- /**
1454
- * Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to Title Case.
1455
- *
1456
- * @example
1457
- * ```ts
1458
- * upperDashToTitle('HELLO-WORLD'); // 'Hello World'
1459
- * upperDashToTitle({ 'FIRST-NAME': 'John' }); // { 'First Name': 'John' }
1460
- * ```
1461
- *
1462
- * @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
1463
- * so results differ for keys like `userID` (see the migration notes in the README).
1464
- */
1465
- function upperDashToTitle(input) {
1466
- return converter(input, "UpperDashToTitle");
1467
- }
1468
- /**
1469
- * Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to Sentence case.
1470
- *
1471
- * @example
1472
- * ```ts
1473
- * upperDashToSentence('HELLO-WORLD'); // 'Hello world'
1474
- * upperDashToSentence({ 'FIRST-NAME': 'John' }); // { 'First name': 'John' }
1475
- * ```
1476
- *
1477
- * @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
1478
- * so results differ for keys like `userID` (see the migration notes in the README).
1479
- */
1480
- function upperDashToSentence(input) {
1481
- return converter(input, "UpperDashToSentence");
1482
- }
1483
- //#endregion
1484
- //#region src/upperSnakeCase/upperSnakeCase.ts
1485
- /**
1486
- * Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to camelCase.
1487
- *
1488
- * @example
1489
- * ```ts
1490
- * upperSnakeToCamel('HELLO_WORLD'); // 'helloWorld'
1491
- * upperSnakeToCamel({ FIRST_NAME: 'John' }); // { firstName: 'John' }
1492
- * ```
1493
- *
1494
- * @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
1495
- * so results differ for keys like `userID` (see the migration notes in the README).
1496
- */
1497
- function upperSnakeToCamel(input) {
1498
- return converter(input, "UpperSnakeToCamel");
1499
- }
1500
- /**
1501
- * Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to snake_case.
1502
- *
1503
- * @example
1504
- * ```ts
1505
- * upperSnakeToSnake('HELLO_WORLD'); // 'hello_world'
1506
- * upperSnakeToSnake({ FIRST_NAME: 'John' }); // { first_name: 'John' }
1507
- * ```
1508
- *
1509
- * @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
1510
- * so results differ for keys like `userID` (see the migration notes in the README).
1511
- */
1512
- function upperSnakeToSnake(input) {
1513
- return converter(input, "UpperSnakeToSnake");
1514
- }
1515
- /**
1516
- * Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to dash-case.
1517
- *
1518
- * @example
1519
- * ```ts
1520
- * upperSnakeToDash('HELLO_WORLD'); // 'hello-world'
1521
- * upperSnakeToDash({ FIRST_NAME: 'John' }); // { 'first-name': 'John' }
1522
- * ```
1523
- *
1524
- * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
1525
- * so results differ for keys like `userID` (see the migration notes in the README).
1526
- */
1527
- function upperSnakeToDash(input) {
1528
- return converter(input, "UpperSnakeToDash");
1529
- }
1530
- /**
1531
- * Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to PascalCase.
1532
- *
1533
- * @example
1534
- * ```ts
1535
- * upperSnakeToPascal('HELLO_WORLD'); // 'HelloWorld'
1536
- * upperSnakeToPascal({ FIRST_NAME: 'John' }); // { FirstName: 'John' }
1537
- * ```
1538
- *
1539
- * @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
1540
- * so results differ for keys like `userID` (see the migration notes in the README).
1541
- */
1542
- function upperSnakeToPascal(input) {
1543
- return converter(input, "UpperSnakeToPascal");
1544
- }
1545
- /**
1546
- * Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to UPPER-DASH-CASE.
1547
- *
1548
- * @example
1549
- * ```ts
1550
- * upperSnakeToUpperDash('HELLO_WORLD'); // 'HELLO-WORLD'
1551
- * upperSnakeToUpperDash({ FIRST_NAME: 'John' }); // { 'FIRST-NAME': 'John' }
1552
- * ```
1553
- *
1554
- * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
1555
- * so results differ for keys like `userID` (see the migration notes in the README).
1556
- */
1557
- function upperSnakeToUpperDash(input) {
1558
- return converter(input, "UpperSnakeToUpperDash");
1559
- }
1560
- /**
1561
- * Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to Train-Case.
1562
- *
1563
- * @example
1564
- * ```ts
1565
- * upperSnakeToTrain('HELLO_WORLD'); // 'Hello-World'
1566
- * upperSnakeToTrain({ FIRST_NAME: 'John' }); // { 'First-Name': 'John' }
1567
- * ```
1568
- *
1569
- * @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
1570
- * so results differ for keys like `userID` (see the migration notes in the README).
1571
- */
1572
- function upperSnakeToTrain(input) {
1573
- return converter(input, "UpperSnakeToTrain");
1574
- }
1575
- /**
1576
- * Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to dot.case.
1577
- *
1578
- * @example
1579
- * ```ts
1580
- * upperSnakeToDot('HELLO_WORLD'); // 'hello.world'
1581
- * upperSnakeToDot({ FIRST_NAME: 'John' }); // { 'first.name': 'John' }
1582
- * ```
1583
- *
1584
- * @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
1585
- * so results differ for keys like `userID` (see the migration notes in the README).
1586
- */
1587
- function upperSnakeToDot(input) {
1588
- return converter(input, "UpperSnakeToDot");
1589
- }
1590
- /**
1591
- * Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to Title Case.
1592
- *
1593
- * @example
1594
- * ```ts
1595
- * upperSnakeToTitle('HELLO_WORLD'); // 'Hello World'
1596
- * upperSnakeToTitle({ FIRST_NAME: 'John' }); // { 'First Name': 'John' }
1597
- * ```
1598
- *
1599
- * @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
1600
- * so results differ for keys like `userID` (see the migration notes in the README).
1601
- */
1602
- function upperSnakeToTitle(input) {
1603
- return converter(input, "UpperSnakeToTitle");
1604
- }
1605
- /**
1606
- * Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to Sentence case.
1607
- *
1608
- * @example
1609
- * ```ts
1610
- * upperSnakeToSentence('HELLO_WORLD'); // 'Hello world'
1611
- * upperSnakeToSentence({ FIRST_NAME: 'John' }); // { 'First name': 'John' }
1612
- * ```
1613
- *
1614
- * @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
1615
- * so results differ for keys like `userID` (see the migration notes in the README).
1616
- */
1617
- function upperSnakeToSentence(input) {
1618
- return converter(input, "UpperSnakeToSentence");
59
+ const array = isArray(input);
60
+ if (!array && !isObject(input)) return void 0;
61
+ const context = { convertKey };
62
+ if (ignore) {
63
+ context.cache = /* @__PURE__ */ new Map();
64
+ for (const key of ignore) context.cache.set(key, key);
65
+ }
66
+ return array ? arrayParser(input, context) : objectParser(input, context);
1619
67
  }
1620
- //#endregion
1621
- //#region src/anyCase/words.ts
68
+ // src/anyCase/words.ts
1622
69
  const SYMBOLS = "!\"#$%&'()*+,/:;<=>?@[\\]^`{|}~";
1623
- const isSeparator = (c) => c === "_" || c === "-" || c === "." || c === " ";
1624
- const isSymbol = (c) => SYMBOLS.indexOf(c) !== -1;
1625
- const isUpper = (c) => c !== c.toLowerCase();
1626
- const isLower = (c) => c !== c.toUpperCase();
1627
- const isKept = (c, keep) => keep === true || typeof keep !== "boolean" && keep !== void 0 && keep !== null && keep.indexOf(c) !== -1;
70
+ const OTHER = 0;
71
+ const SEPARATOR = 1;
72
+ const SYMBOL = 2;
73
+ const UPPER = 3;
74
+ const LOWER = 4;
75
+ const KINDS = /* @__PURE__ */ new Uint8Array(128);
76
+ for (let code = 65; code <= 90; code++) KINDS[code] = UPPER;
77
+ for (let code = 97; code <= 122; code++) KINDS[code] = LOWER;
78
+ for (let i = 0; i < 29; i++) KINDS[SYMBOLS.charCodeAt(i)] = SYMBOL;
79
+ for (const separator of "_-. ") KINDS[separator.charCodeAt(0)] = SEPARATOR;
80
+ const PATH_KINDS = KINDS.slice();
81
+ PATH_KINDS[47] = SEPARATOR;
82
+ PATH_KINDS[92] = SEPARATOR;
83
+ function kindAt(str, i, kinds) {
84
+ const code = str.charCodeAt(i);
85
+ if (code < 128) return kinds[code];
86
+ const c = str[i];
87
+ if (c !== c.toLowerCase()) return UPPER;
88
+ return c !== c.toUpperCase() ? LOWER : OTHER;
89
+ }
90
+ function isLowerAt(str, i) {
91
+ if (i >= str.length) return false;
92
+ const code = str.charCodeAt(i);
93
+ if (code < 128) return KINDS[code] === LOWER;
94
+ const c = str[i];
95
+ return c !== c.toUpperCase();
96
+ }
97
+ function toKeep(allowSymbols) {
98
+ if (allowSymbols === true) return true;
99
+ if (!allowSymbols) return false;
100
+ const table = /* @__PURE__ */ new Uint8Array(128);
101
+ for (let i = 0; i < 29; i++) if (allowSymbols.indexOf(SYMBOLS[i]) !== -1) table[SYMBOLS.charCodeAt(i)] = 1;
102
+ return table;
103
+ }
104
+ const NONE = 0;
105
+ const PREV_UPPER = 1;
106
+ const PREV_OTHER = 2;
107
+ const HAS_UPPER = 1;
108
+ const HAS_NON_ASCII = 2;
109
+ function toCase(word, flags, wordCase) {
110
+ if (wordCase === "lower") return flags === 0 ? word : word.toLowerCase();
111
+ if (wordCase === "upper") return flags & HAS_NON_ASCII ? word.toLowerCase().toUpperCase() : word.toUpperCase();
112
+ return word;
113
+ }
1628
114
  /**
1629
115
  * Splits a string in any case into lowercase words: on `_`, `-`, `.` and spaces,
1630
116
  * before an uppercase letter that follows a lowercase letter or a digit (`helloWorld`),
@@ -1633,196 +119,177 @@ const isKept = (c, keep) => keep === true || typeof keep !== "boolean" && keep !
1633
119
  * Symbols (ASCII punctuation) also start a new word. They are removed, unless `keep` is
1634
120
  * `true` or lists them: a kept symbol sticks to the start of the next word (`hello$World`
1635
121
  * → `hello`, `$world`), or to the end of the previous one when no word follows (`total%`).
1636
- * Words keep their original case when `lowercase` is `false`.
122
+ * Words are uppercased when `wordCase` is `'upper'`, and keep their original case when it's `'keep'`.
1637
123
  */
1638
- function words(str, keep = false, lowercase = true) {
124
+ function words(str, keep = false, wordCase = "lower", path = false) {
125
+ const kinds = path ? PATH_KINDS : KINDS;
126
+ const length = str.length;
1639
127
  const result = [];
1640
- let word = "";
1641
- let prev = "";
1642
- const push = () => {
1643
- if (word) result.push(lowercase ? word.toLowerCase() : word);
1644
- word = "";
1645
- };
1646
- for (let i = 0; i < str.length; i++) {
1647
- const c = str[i];
1648
- if (isSeparator(c)) {
1649
- push();
1650
- prev = "";
128
+ let start = 0;
129
+ let prefix = "";
130
+ let flags = 0;
131
+ let prev = NONE;
132
+ for (let i = 0; i < length; i++) {
133
+ const kind = kindAt(str, i, kinds);
134
+ if (kind === SEPARATOR) {
135
+ if (i > start || prefix) result.push(toCase(prefix + str.slice(start, i), flags, wordCase));
136
+ start = i + 1;
137
+ prefix = "";
138
+ flags = 0;
139
+ prev = NONE;
1651
140
  continue;
1652
141
  }
1653
- if (isSymbol(c)) {
142
+ if (kind === SYMBOL) {
1654
143
  let kept = "";
1655
144
  let j = i;
1656
- for (; j < str.length && isSymbol(str[j]); j++) if (isKept(str[j], keep)) kept += str[j];
1657
- const next = str.charAt(j);
1658
- if (next && !isSeparator(next)) {
1659
- push();
1660
- prev = "";
145
+ for (; j < length; j++) {
146
+ const code = str.charCodeAt(j);
147
+ if (code >= 128 || kinds[code] !== SYMBOL) break;
148
+ if (keep === true || keep !== false && keep[code] === 1) kept += str[j];
149
+ }
150
+ const word = prefix + str.slice(start, i);
151
+ if (j < length && kinds[str.charCodeAt(j)] !== SEPARATOR) {
152
+ if (word) result.push(toCase(word, flags, wordCase));
153
+ prefix = kept;
154
+ prev = NONE;
155
+ } else if (word || kept) {
156
+ result.push(toCase(word + kept, flags, wordCase));
157
+ prefix = "";
1661
158
  }
1662
- word += kept;
159
+ flags = 0;
160
+ start = j;
1663
161
  i = j - 1;
1664
162
  continue;
1665
163
  }
1666
- const next = str.charAt(i + 1);
1667
- if (isUpper(c) && prev && (!isUpper(prev) || next && isLower(next))) push();
1668
- word += c;
1669
- prev = c;
164
+ if (kind === UPPER) {
165
+ if (prev !== NONE && (prev !== PREV_UPPER || isLowerAt(str, i + 1))) {
166
+ const word = prefix + str.slice(start, i);
167
+ if (word) result.push(toCase(word, flags, wordCase));
168
+ start = i;
169
+ prefix = "";
170
+ flags = 0;
171
+ }
172
+ flags |= HAS_UPPER;
173
+ prev = PREV_UPPER;
174
+ } else prev = PREV_OTHER;
175
+ if (str.charCodeAt(i) >= 128) flags |= HAS_NON_ASCII;
1670
176
  }
1671
- push();
177
+ if (length > start || prefix) result.push(toCase(prefix + str.slice(start), flags, wordCase));
1672
178
  return result;
1673
179
  }
1674
180
  /** Uppercases the first character that is not a symbol: `'$id'` → `'$Id'`. */
1675
181
  function capitalize(word) {
182
+ const code = word.charCodeAt(0);
183
+ if (code >= 97 && code <= 122) return String.fromCharCode(code - 32) + word.slice(1);
1676
184
  let i = 0;
1677
- while (i < word.length && isSymbol(word[i])) i++;
185
+ while (i < word.length && word.charCodeAt(i) < 128 && KINDS[word.charCodeAt(i)] === SYMBOL) i++;
1678
186
  return word.slice(0, i) + word.charAt(i).toUpperCase() + word.slice(i + 1);
1679
187
  }
188
+ function join(list, separator, first, rest) {
189
+ let result = "";
190
+ for (let i = 0; i < list.length; i++) if (i === 0) result = first ? capitalize(list[0]) : list[0];
191
+ else result += separator + (rest ? capitalize(list[i]) : list[i]);
192
+ return result;
193
+ }
1680
194
  /** Changes the case of the whole string, or keeps it when `transform` is `undefined`. */
1681
195
  function applyTransform(str, transform) {
1682
196
  if (transform === "lowercase") return str.toLowerCase();
1683
197
  if (transform === "uppercase") return str.toUpperCase();
1684
198
  return str;
1685
199
  }
1686
- const ToCamel = (str, keep) => words(str, keep).map((w, i) => i ? capitalize(w) : w).join("");
1687
- const ToPascal = (str, keep) => words(str, keep).map(capitalize).join("");
1688
- const ToSnake = (str, keep) => words(str, keep).join("_");
1689
- const ToKebab = (str, keep) => words(str, keep).join("-");
1690
- const ToUpperSnake = (str, keep) => words(str, keep).join("_").toUpperCase();
1691
- const ToUpperKebab = (str, keep) => words(str, keep).join("-").toUpperCase();
1692
- const ToTrain = (str, keep) => words(str, keep).map(capitalize).join("-");
1693
- const ToDot = (str, keep, transform) => applyTransform(words(str, keep, false).join("."), transform);
1694
- const ToTitle = (str, keep) => words(str, keep).map(capitalize).join(" ");
1695
- const ToSentence = (str, keep) => capitalize(words(str, keep).join(" "));
1696
- const ToPascalSnake = (str, keep) => words(str, keep).map(capitalize).join("_");
1697
- const ToPath = (str, keep, transform, separator = "/") => applyTransform(words(str.replace(/[/\\]/g, " "), keep, false).join(separator), transform);
1698
- const ToSpace = (str, keep) => words(str, keep, false).join(" ");
1699
- const ToLower = (str, keep) => words(str, keep).join(" ");
1700
- const ToUpper = (str, keep) => words(str, keep).join(" ").toUpperCase();
1701
- //#endregion
1702
- //#region src/anyCase/anyCase.ts
200
+ const ToCamel = (str, keep) => join(words(str, keep), "", false, true);
201
+ const ToPascal = (str, keep) => join(words(str, keep), "", true, true);
202
+ const ToSnake = (str, keep) => join(words(str, keep), "_", false, false);
203
+ const ToKebab = (str, keep) => join(words(str, keep), "-", false, false);
204
+ const ToUpperSnake = (str, keep) => join(words(str, keep, "upper"), "_", false, false);
205
+ const ToUpperKebab = (str, keep) => join(words(str, keep, "upper"), "-", false, false);
206
+ const ToTrain = (str, keep) => join(words(str, keep), "-", true, true);
207
+ const ToDot = (str, keep, transform) => applyTransform(join(words(str, keep, "keep"), ".", false, false), transform);
208
+ const ToTitle = (str, keep) => join(words(str, keep), " ", true, true);
209
+ const ToSentence = (str, keep) => join(words(str, keep), " ", true, false);
210
+ const ToPascalSnake = (str, keep) => join(words(str, keep), "_", true, true);
211
+ const ToPath = (str, keep, transform, separator = "/") => applyTransform(join(words(str, keep, "keep", true), separator, false, false), transform);
212
+ const ToSpace = (str, keep) => join(words(str, keep, "keep"), " ", false, false);
213
+ const ToLower = (str, keep) => join(words(str, keep), " ", false, false);
214
+ const ToUpper = (str, keep) => join(words(str, keep, "upper"), " ", false, false);
215
+ // src/anyCase/anyCase.ts
216
+ const KEEP_NONE = { keep: false };
217
+ const KEEP_ALL = { keep: true };
1703
218
  /** Reads the second argument of a `toX` function: the `allowSymbols` shorthand, or an options object. */
1704
219
  function parseOptions(options) {
220
+ if (options === void 0 || options === false) return KEEP_NONE;
221
+ if (options === true) return KEEP_ALL;
1705
222
  if (typeof options === "object" && options !== null && !Array.isArray(options)) {
1706
- const { allowSymbols, transform, separator } = options;
223
+ const { allowSymbols, transform, separator, ignore } = options;
1707
224
  return {
1708
- allowSymbols,
225
+ keep: toKeep(allowSymbols),
1709
226
  transform,
1710
- separator
227
+ separator,
228
+ ignore
1711
229
  };
1712
230
  }
1713
- return { allowSymbols: options };
231
+ return { keep: toKeep(options) };
1714
232
  }
1715
233
  function toCamel(input, options) {
1716
- return convert(input, (key) => ToCamel(key, parseOptions(options).allowSymbols));
234
+ const { keep, ignore } = parseOptions(options);
235
+ return convert(input, (key) => ToCamel(key, keep), ignore);
1717
236
  }
1718
237
  function toPascal(input, options) {
1719
- return convert(input, (key) => ToPascal(key, parseOptions(options).allowSymbols));
238
+ const { keep, ignore } = parseOptions(options);
239
+ return convert(input, (key) => ToPascal(key, keep), ignore);
1720
240
  }
1721
241
  function toSnake(input, options) {
1722
- return convert(input, (key) => ToSnake(key, parseOptions(options).allowSymbols));
242
+ const { keep, ignore } = parseOptions(options);
243
+ return convert(input, (key) => ToSnake(key, keep), ignore);
1723
244
  }
1724
245
  function toKebab(input, options) {
1725
- return convert(input, (key) => ToKebab(key, parseOptions(options).allowSymbols));
246
+ const { keep, ignore } = parseOptions(options);
247
+ return convert(input, (key) => ToKebab(key, keep), ignore);
1726
248
  }
1727
249
  function toUpperSnake(input, options) {
1728
- return convert(input, (key) => ToUpperSnake(key, parseOptions(options).allowSymbols));
250
+ const { keep, ignore } = parseOptions(options);
251
+ return convert(input, (key) => ToUpperSnake(key, keep), ignore);
1729
252
  }
1730
253
  function toUpperKebab(input, options) {
1731
- return convert(input, (key) => ToUpperKebab(key, parseOptions(options).allowSymbols));
254
+ const { keep, ignore } = parseOptions(options);
255
+ return convert(input, (key) => ToUpperKebab(key, keep), ignore);
1732
256
  }
1733
257
  function toTrain(input, options) {
1734
- return convert(input, (key) => ToTrain(key, parseOptions(options).allowSymbols));
258
+ const { keep, ignore } = parseOptions(options);
259
+ return convert(input, (key) => ToTrain(key, keep), ignore);
1735
260
  }
1736
261
  function toDot(input, options) {
1737
- const { allowSymbols, transform } = parseOptions(options);
1738
- return convert(input, (key) => ToDot(key, allowSymbols, transform));
262
+ const { keep, transform, ignore } = parseOptions(options);
263
+ return convert(input, (key) => ToDot(key, keep, transform), ignore);
1739
264
  }
1740
265
  function toTitle(input, options) {
1741
- return convert(input, (key) => ToTitle(key, parseOptions(options).allowSymbols));
266
+ const { keep, ignore } = parseOptions(options);
267
+ return convert(input, (key) => ToTitle(key, keep), ignore);
1742
268
  }
1743
269
  function toSentence(input, options) {
1744
- return convert(input, (key) => ToSentence(key, parseOptions(options).allowSymbols));
270
+ const { keep, ignore } = parseOptions(options);
271
+ return convert(input, (key) => ToSentence(key, keep), ignore);
1745
272
  }
1746
273
  function toPascalSnake(input, options) {
1747
- return convert(input, (key) => ToPascalSnake(key, parseOptions(options).allowSymbols));
274
+ const { keep, ignore } = parseOptions(options);
275
+ return convert(input, (key) => ToPascalSnake(key, keep), ignore);
1748
276
  }
1749
277
  function toPath(input, options) {
1750
- const { allowSymbols, transform, separator } = parseOptions(options);
1751
- return convert(input, (key) => ToPath(key, allowSymbols, transform, separator === "\\" ? "\\" : "/"));
278
+ const { keep, transform, separator, ignore } = parseOptions(options);
279
+ return convert(input, (key) => ToPath(key, keep, transform, separator === "\\" ? "\\" : "/"), ignore);
1752
280
  }
1753
281
  function toSpace(input, options) {
1754
- return convert(input, (key) => ToSpace(key, parseOptions(options).allowSymbols));
282
+ const { keep, ignore } = parseOptions(options);
283
+ return convert(input, (key) => ToSpace(key, keep), ignore);
1755
284
  }
1756
285
  function toLower(input, options) {
1757
- return convert(input, (key) => ToLower(key, parseOptions(options).allowSymbols));
286
+ const { keep, ignore } = parseOptions(options);
287
+ return convert(input, (key) => ToLower(key, keep), ignore);
1758
288
  }
1759
289
  function toUpper(input, options) {
1760
- return convert(input, (key) => ToUpper(key, parseOptions(options).allowSymbols));
290
+ const { keep, ignore } = parseOptions(options);
291
+ return convert(input, (key) => ToUpper(key, keep), ignore);
1761
292
  }
1762
- //#endregion
1763
- exports.camelToDash = camelToDash;
1764
- exports.camelToDot = camelToDot;
1765
- exports.camelToPascal = camelToPascal;
1766
- exports.camelToSentence = camelToSentence;
1767
- exports.camelToSnake = camelToSnake;
1768
- exports.camelToTitle = camelToTitle;
1769
- exports.camelToTrain = camelToTrain;
1770
- exports.camelToUpperDash = camelToUpperDash;
1771
- exports.camelToUpperSnake = camelToUpperSnake;
1772
- exports.dashToCamel = dashToCamel;
1773
- exports.dashToDot = dashToDot;
1774
- exports.dashToPascal = dashToPascal;
1775
- exports.dashToSentence = dashToSentence;
1776
- exports.dashToSnake = dashToSnake;
1777
- exports.dashToTitle = dashToTitle;
1778
- exports.dashToTrain = dashToTrain;
1779
- exports.dashToUpperDash = dashToUpperDash;
1780
- exports.dashToUpperSnake = dashToUpperSnake;
1781
- exports.dotToCamel = dotToCamel;
1782
- exports.dotToDash = dotToDash;
1783
- exports.dotToPascal = dotToPascal;
1784
- exports.dotToSentence = dotToSentence;
1785
- exports.dotToSnake = dotToSnake;
1786
- exports.dotToTitle = dotToTitle;
1787
- exports.dotToTrain = dotToTrain;
1788
- exports.dotToUpperDash = dotToUpperDash;
1789
- exports.dotToUpperSnake = dotToUpperSnake;
1790
- exports.pascalToCamel = pascalToCamel;
1791
- exports.pascalToDash = pascalToDash;
1792
- exports.pascalToDot = pascalToDot;
1793
- exports.pascalToSentence = pascalToSentence;
1794
- exports.pascalToSnake = pascalToSnake;
1795
- exports.pascalToTitle = pascalToTitle;
1796
- exports.pascalToTrain = pascalToTrain;
1797
- exports.pascalToUpperDash = pascalToUpperDash;
1798
- exports.pascalToUpperSnake = pascalToUpperSnake;
1799
- exports.sentenceToCamel = sentenceToCamel;
1800
- exports.sentenceToDash = sentenceToDash;
1801
- exports.sentenceToDot = sentenceToDot;
1802
- exports.sentenceToPascal = sentenceToPascal;
1803
- exports.sentenceToSnake = sentenceToSnake;
1804
- exports.sentenceToTitle = sentenceToTitle;
1805
- exports.sentenceToTrain = sentenceToTrain;
1806
- exports.sentenceToUpperDash = sentenceToUpperDash;
1807
- exports.sentenceToUpperSnake = sentenceToUpperSnake;
1808
- exports.snakeToCamel = snakeToCamel;
1809
- exports.snakeToDash = snakeToDash;
1810
- exports.snakeToDot = snakeToDot;
1811
- exports.snakeToPascal = snakeToPascal;
1812
- exports.snakeToSentence = snakeToSentence;
1813
- exports.snakeToTitle = snakeToTitle;
1814
- exports.snakeToTrain = snakeToTrain;
1815
- exports.snakeToUpperDash = snakeToUpperDash;
1816
- exports.snakeToUpperSnake = snakeToUpperSnake;
1817
- exports.titleToCamel = titleToCamel;
1818
- exports.titleToDash = titleToDash;
1819
- exports.titleToDot = titleToDot;
1820
- exports.titleToPascal = titleToPascal;
1821
- exports.titleToSentence = titleToSentence;
1822
- exports.titleToSnake = titleToSnake;
1823
- exports.titleToTrain = titleToTrain;
1824
- exports.titleToUpperDash = titleToUpperDash;
1825
- exports.titleToUpperSnake = titleToUpperSnake;
1826
293
  exports.toCamel = toCamel;
1827
294
  exports.toDot = toDot;
1828
295
  exports.toKebab = toKebab;
@@ -1838,30 +305,3 @@ exports.toTrain = toTrain;
1838
305
  exports.toUpper = toUpper;
1839
306
  exports.toUpperKebab = toUpperKebab;
1840
307
  exports.toUpperSnake = toUpperSnake;
1841
- exports.trainToCamel = trainToCamel;
1842
- exports.trainToDash = trainToDash;
1843
- exports.trainToDot = trainToDot;
1844
- exports.trainToPascal = trainToPascal;
1845
- exports.trainToSentence = trainToSentence;
1846
- exports.trainToSnake = trainToSnake;
1847
- exports.trainToTitle = trainToTitle;
1848
- exports.trainToUpperDash = trainToUpperDash;
1849
- exports.trainToUpperSnake = trainToUpperSnake;
1850
- exports.upperDashToCamel = upperDashToCamel;
1851
- exports.upperDashToDash = upperDashToDash;
1852
- exports.upperDashToDot = upperDashToDot;
1853
- exports.upperDashToPascal = upperDashToPascal;
1854
- exports.upperDashToSentence = upperDashToSentence;
1855
- exports.upperDashToSnake = upperDashToSnake;
1856
- exports.upperDashToTitle = upperDashToTitle;
1857
- exports.upperDashToTrain = upperDashToTrain;
1858
- exports.upperDashToUpperSnake = upperDashToUpperSnake;
1859
- exports.upperSnakeToCamel = upperSnakeToCamel;
1860
- exports.upperSnakeToDash = upperSnakeToDash;
1861
- exports.upperSnakeToDot = upperSnakeToDot;
1862
- exports.upperSnakeToPascal = upperSnakeToPascal;
1863
- exports.upperSnakeToSentence = upperSnakeToSentence;
1864
- exports.upperSnakeToSnake = upperSnakeToSnake;
1865
- exports.upperSnakeToTitle = upperSnakeToTitle;
1866
- exports.upperSnakeToTrain = upperSnakeToTrain;
1867
- exports.upperSnakeToUpperDash = upperSnakeToUpperDash;