caseparser 5.0.0 → 6.0.0

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