caseparser 5.1.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,1629 +1,115 @@
1
- //#region src/utils.ts
1
+ // src/utils.ts
2
2
  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) {
13
+ // src/parser/objectParser.ts
14
+ function objectParser(input, context) {
26
15
  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,
16
+ const keys = Object.keys(input);
17
+ for (let i = 0; i < keys.length; i++) {
18
+ const key = keys[i];
19
+ const { cache } = context;
20
+ let parsedKey = cache === null || cache === void 0 ? void 0 : cache.get(key);
21
+ if (parsedKey === void 0) {
22
+ parsedKey = context.convertKey(key);
23
+ cache === null || cache === void 0 || cache.set(key, parsedKey);
24
+ }
25
+ let value = input[key];
26
+ if (typeof value === "object" && value !== null) {
27
+ if (Array.isArray(value)) value = arrayParser(value, context);
28
+ else if (isObject(value)) value = objectParser(value, context);
29
+ }
30
+ if (parsedKey === "__proto__") Object.defineProperty(result, parsedKey, {
31
+ value,
36
32
  enumerable: true,
37
33
  writable: true,
38
34
  configurable: true
39
35
  });
36
+ else result[parsedKey] = value;
40
37
  }
41
38
  return result;
42
39
  }
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);
40
+ // src/parser/arrayParser.ts
41
+ function arrayParser(input, context) {
42
+ if (!context.cache) context.cache = /* @__PURE__ */ new Map();
43
+ const length = input.length;
44
+ const result = new Array(length);
45
+ for (let i = 0; i < length; i++) {
46
+ const item = input[i];
47
+ if (typeof item === "object" && item !== null) {
48
+ if (Array.isArray(item)) result[i] = arrayParser(item, context);
49
+ else result[i] = isObject(item) ? objectParser(item, context) : item;
50
+ } else result[i] = item;
51
+ }
52
+ return result;
237
53
  }
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) {
54
+ // src/parser/parser.ts
55
+ /** Converts a string, or the keys of an object/array (deeply), with `convertKey`. Keys in `ignore` are kept as they are. */
56
+ function convert(input, convertKey, ignore) {
242
57
  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
- //#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");
1344
- }
1345
- //#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");
1481
- }
1482
- //#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");
58
+ const array = isArray(input);
59
+ if (!array && !isObject(input)) return void 0;
60
+ const context = { convertKey };
61
+ if (ignore) {
62
+ context.cache = /* @__PURE__ */ new Map();
63
+ for (const key of ignore) context.cache.set(key, key);
64
+ }
65
+ return array ? arrayParser(input, context) : objectParser(input, context);
1618
66
  }
1619
- //#endregion
1620
- //#region src/anyCase/words.ts
67
+ // src/anyCase/words.ts
1621
68
  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;
69
+ const OTHER = 0;
70
+ const SEPARATOR = 1;
71
+ const SYMBOL = 2;
72
+ const UPPER = 3;
73
+ const LOWER = 4;
74
+ const KINDS = /* @__PURE__ */ new Uint8Array(128);
75
+ for (let code = 65; code <= 90; code++) KINDS[code] = UPPER;
76
+ for (let code = 97; code <= 122; code++) KINDS[code] = LOWER;
77
+ for (let i = 0; i < 29; i++) KINDS[SYMBOLS.charCodeAt(i)] = SYMBOL;
78
+ for (const separator of "_-. ") KINDS[separator.charCodeAt(0)] = SEPARATOR;
79
+ const PATH_KINDS = KINDS.slice();
80
+ PATH_KINDS[47] = SEPARATOR;
81
+ PATH_KINDS[92] = SEPARATOR;
82
+ function kindAt(str, i, kinds) {
83
+ const code = str.charCodeAt(i);
84
+ if (code < 128) return kinds[code];
85
+ const c = str[i];
86
+ if (c !== c.toLowerCase()) return UPPER;
87
+ return c !== c.toUpperCase() ? LOWER : OTHER;
88
+ }
89
+ function isLowerAt(str, i) {
90
+ if (i >= str.length) return false;
91
+ const code = str.charCodeAt(i);
92
+ if (code < 128) return KINDS[code] === LOWER;
93
+ const c = str[i];
94
+ return c !== c.toUpperCase();
95
+ }
96
+ function toKeep(allowSymbols) {
97
+ if (allowSymbols === true) return true;
98
+ if (!allowSymbols) return false;
99
+ const table = /* @__PURE__ */ new Uint8Array(128);
100
+ for (let i = 0; i < 29; i++) if (allowSymbols.indexOf(SYMBOLS[i]) !== -1) table[SYMBOLS.charCodeAt(i)] = 1;
101
+ return table;
102
+ }
103
+ const NONE = 0;
104
+ const PREV_UPPER = 1;
105
+ const PREV_OTHER = 2;
106
+ const HAS_UPPER = 1;
107
+ const HAS_NON_ASCII = 2;
108
+ function toCase(word, flags, wordCase) {
109
+ if (wordCase === "lower") return flags === 0 ? word : word.toLowerCase();
110
+ if (wordCase === "upper") return flags & HAS_NON_ASCII ? word.toLowerCase().toUpperCase() : word.toUpperCase();
111
+ return word;
112
+ }
1627
113
  /**
1628
114
  * Splits a string in any case into lowercase words: on `_`, `-`, `.` and spaces,
1629
115
  * before an uppercase letter that follows a lowercase letter or a digit (`helloWorld`),
@@ -1632,131 +118,175 @@ const isKept = (c, keep) => keep === true || typeof keep !== "boolean" && keep !
1632
118
  * Symbols (ASCII punctuation) also start a new word. They are removed, unless `keep` is
1633
119
  * `true` or lists them: a kept symbol sticks to the start of the next word (`hello$World`
1634
120
  * → `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`.
121
+ * Words are uppercased when `wordCase` is `'upper'`, and keep their original case when it's `'keep'`.
1636
122
  */
1637
- function words(str, keep = false, lowercase = true) {
123
+ function words(str, keep = false, wordCase = "lower", path = false) {
124
+ const kinds = path ? PATH_KINDS : KINDS;
125
+ const length = str.length;
1638
126
  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 = "";
127
+ let start = 0;
128
+ let prefix = "";
129
+ let flags = 0;
130
+ let prev = NONE;
131
+ for (let i = 0; i < length; i++) {
132
+ const kind = kindAt(str, i, kinds);
133
+ if (kind === SEPARATOR) {
134
+ if (i > start || prefix) result.push(toCase(prefix + str.slice(start, i), flags, wordCase));
135
+ start = i + 1;
136
+ prefix = "";
137
+ flags = 0;
138
+ prev = NONE;
1650
139
  continue;
1651
140
  }
1652
- if (isSymbol(c)) {
141
+ if (kind === SYMBOL) {
1653
142
  let kept = "";
1654
143
  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 = "";
144
+ for (; j < length; j++) {
145
+ const code = str.charCodeAt(j);
146
+ if (code >= 128 || kinds[code] !== SYMBOL) break;
147
+ if (keep === true || keep !== false && keep[code] === 1) kept += str[j];
148
+ }
149
+ const word = prefix + str.slice(start, i);
150
+ if (j < length && kinds[str.charCodeAt(j)] !== SEPARATOR) {
151
+ if (word) result.push(toCase(word, flags, wordCase));
152
+ prefix = kept;
153
+ prev = NONE;
154
+ } else if (word || kept) {
155
+ result.push(toCase(word + kept, flags, wordCase));
156
+ prefix = "";
1660
157
  }
1661
- word += kept;
158
+ flags = 0;
159
+ start = j;
1662
160
  i = j - 1;
1663
161
  continue;
1664
162
  }
1665
- const next = str.charAt(i + 1);
1666
- if (isUpper(c) && prev && (!isUpper(prev) || next && isLower(next))) push();
1667
- word += c;
1668
- prev = c;
163
+ if (kind === UPPER) {
164
+ if (prev !== NONE && (prev !== PREV_UPPER || isLowerAt(str, i + 1))) {
165
+ const word = prefix + str.slice(start, i);
166
+ if (word) result.push(toCase(word, flags, wordCase));
167
+ start = i;
168
+ prefix = "";
169
+ flags = 0;
170
+ }
171
+ flags |= HAS_UPPER;
172
+ prev = PREV_UPPER;
173
+ } else prev = PREV_OTHER;
174
+ if (str.charCodeAt(i) >= 128) flags |= HAS_NON_ASCII;
1669
175
  }
1670
- push();
176
+ if (length > start || prefix) result.push(toCase(prefix + str.slice(start), flags, wordCase));
1671
177
  return result;
1672
178
  }
1673
179
  /** Uppercases the first character that is not a symbol: `'$id'` → `'$Id'`. */
1674
180
  function capitalize(word) {
181
+ const code = word.charCodeAt(0);
182
+ if (code >= 97 && code <= 122) return String.fromCharCode(code - 32) + word.slice(1);
1675
183
  let i = 0;
1676
- while (i < word.length && isSymbol(word[i])) i++;
184
+ while (i < word.length && word.charCodeAt(i) < 128 && KINDS[word.charCodeAt(i)] === SYMBOL) i++;
1677
185
  return word.slice(0, i) + word.charAt(i).toUpperCase() + word.slice(i + 1);
1678
186
  }
187
+ function join(list, separator, first, rest) {
188
+ let result = "";
189
+ for (let i = 0; i < list.length; i++) if (i === 0) result = first ? capitalize(list[0]) : list[0];
190
+ else result += separator + (rest ? capitalize(list[i]) : list[i]);
191
+ return result;
192
+ }
1679
193
  /** Changes the case of the whole string, or keeps it when `transform` is `undefined`. */
1680
194
  function applyTransform(str, transform) {
1681
195
  if (transform === "lowercase") return str.toLowerCase();
1682
196
  if (transform === "uppercase") return str.toUpperCase();
1683
197
  return str;
1684
198
  }
1685
- const ToCamel = (str, keep) => words(str, keep).map((w, i) => i ? capitalize(w) : w).join("");
1686
- const ToPascal = (str, keep) => words(str, keep).map(capitalize).join("");
1687
- const ToSnake = (str, keep) => words(str, keep).join("_");
1688
- const ToKebab = (str, keep) => words(str, keep).join("-");
1689
- const ToUpperSnake = (str, keep) => words(str, keep).join("_").toUpperCase();
1690
- const ToUpperKebab = (str, keep) => words(str, keep).join("-").toUpperCase();
1691
- const ToTrain = (str, keep) => words(str, keep).map(capitalize).join("-");
1692
- const ToDot = (str, keep, transform) => applyTransform(words(str, keep, false).join("."), transform);
1693
- const ToTitle = (str, keep) => words(str, keep).map(capitalize).join(" ");
1694
- const ToSentence = (str, keep) => capitalize(words(str, keep).join(" "));
1695
- const ToPascalSnake = (str, keep) => words(str, keep).map(capitalize).join("_");
1696
- const ToPath = (str, keep, transform, separator = "/") => applyTransform(words(str.replace(/[/\\]/g, " "), keep, false).join(separator), transform);
1697
- const ToSpace = (str, keep) => words(str, keep, false).join(" ");
1698
- const ToLower = (str, keep) => words(str, keep).join(" ");
1699
- const ToUpper = (str, keep) => words(str, keep).join(" ").toUpperCase();
1700
- //#endregion
1701
- //#region src/anyCase/anyCase.ts
199
+ const ToCamel = (str, keep) => join(words(str, keep), "", false, true);
200
+ const ToPascal = (str, keep) => join(words(str, keep), "", true, true);
201
+ const ToSnake = (str, keep) => join(words(str, keep), "_", false, false);
202
+ const ToKebab = (str, keep) => join(words(str, keep), "-", false, false);
203
+ const ToUpperSnake = (str, keep) => join(words(str, keep, "upper"), "_", false, false);
204
+ const ToUpperKebab = (str, keep) => join(words(str, keep, "upper"), "-", false, false);
205
+ const ToTrain = (str, keep) => join(words(str, keep), "-", true, true);
206
+ const ToDot = (str, keep, transform) => applyTransform(join(words(str, keep, "keep"), ".", false, false), transform);
207
+ const ToTitle = (str, keep) => join(words(str, keep), " ", true, true);
208
+ const ToSentence = (str, keep) => join(words(str, keep), " ", true, false);
209
+ const ToPascalSnake = (str, keep) => join(words(str, keep), "_", true, true);
210
+ const ToPath = (str, keep, transform, separator = "/") => applyTransform(join(words(str, keep, "keep", true), separator, false, false), transform);
211
+ const ToSpace = (str, keep) => join(words(str, keep, "keep"), " ", false, false);
212
+ const ToLower = (str, keep) => join(words(str, keep), " ", false, false);
213
+ const ToUpper = (str, keep) => join(words(str, keep, "upper"), " ", false, false);
214
+ // src/anyCase/anyCase.ts
215
+ const KEEP_NONE = { keep: false };
216
+ const KEEP_ALL = { keep: true };
1702
217
  /** Reads the second argument of a `toX` function: the `allowSymbols` shorthand, or an options object. */
1703
218
  function parseOptions(options) {
219
+ if (options === void 0 || options === false) return KEEP_NONE;
220
+ if (options === true) return KEEP_ALL;
1704
221
  if (typeof options === "object" && options !== null && !Array.isArray(options)) {
1705
- const { allowSymbols, transform, separator } = options;
222
+ const { allowSymbols, transform, separator, ignore } = options;
1706
223
  return {
1707
- allowSymbols,
224
+ keep: toKeep(allowSymbols),
1708
225
  transform,
1709
- separator
226
+ separator,
227
+ ignore
1710
228
  };
1711
229
  }
1712
- return { allowSymbols: options };
230
+ return { keep: toKeep(options) };
1713
231
  }
1714
232
  function toCamel(input, options) {
1715
- return convert(input, (key) => ToCamel(key, parseOptions(options).allowSymbols));
233
+ const { keep, ignore } = parseOptions(options);
234
+ return convert(input, (key) => ToCamel(key, keep), ignore);
1716
235
  }
1717
236
  function toPascal(input, options) {
1718
- return convert(input, (key) => ToPascal(key, parseOptions(options).allowSymbols));
237
+ const { keep, ignore } = parseOptions(options);
238
+ return convert(input, (key) => ToPascal(key, keep), ignore);
1719
239
  }
1720
240
  function toSnake(input, options) {
1721
- return convert(input, (key) => ToSnake(key, parseOptions(options).allowSymbols));
241
+ const { keep, ignore } = parseOptions(options);
242
+ return convert(input, (key) => ToSnake(key, keep), ignore);
1722
243
  }
1723
244
  function toKebab(input, options) {
1724
- return convert(input, (key) => ToKebab(key, parseOptions(options).allowSymbols));
245
+ const { keep, ignore } = parseOptions(options);
246
+ return convert(input, (key) => ToKebab(key, keep), ignore);
1725
247
  }
1726
248
  function toUpperSnake(input, options) {
1727
- return convert(input, (key) => ToUpperSnake(key, parseOptions(options).allowSymbols));
249
+ const { keep, ignore } = parseOptions(options);
250
+ return convert(input, (key) => ToUpperSnake(key, keep), ignore);
1728
251
  }
1729
252
  function toUpperKebab(input, options) {
1730
- return convert(input, (key) => ToUpperKebab(key, parseOptions(options).allowSymbols));
253
+ const { keep, ignore } = parseOptions(options);
254
+ return convert(input, (key) => ToUpperKebab(key, keep), ignore);
1731
255
  }
1732
256
  function toTrain(input, options) {
1733
- return convert(input, (key) => ToTrain(key, parseOptions(options).allowSymbols));
257
+ const { keep, ignore } = parseOptions(options);
258
+ return convert(input, (key) => ToTrain(key, keep), ignore);
1734
259
  }
1735
260
  function toDot(input, options) {
1736
- const { allowSymbols, transform } = parseOptions(options);
1737
- return convert(input, (key) => ToDot(key, allowSymbols, transform));
261
+ const { keep, transform, ignore } = parseOptions(options);
262
+ return convert(input, (key) => ToDot(key, keep, transform), ignore);
1738
263
  }
1739
264
  function toTitle(input, options) {
1740
- return convert(input, (key) => ToTitle(key, parseOptions(options).allowSymbols));
265
+ const { keep, ignore } = parseOptions(options);
266
+ return convert(input, (key) => ToTitle(key, keep), ignore);
1741
267
  }
1742
268
  function toSentence(input, options) {
1743
- return convert(input, (key) => ToSentence(key, parseOptions(options).allowSymbols));
269
+ const { keep, ignore } = parseOptions(options);
270
+ return convert(input, (key) => ToSentence(key, keep), ignore);
1744
271
  }
1745
272
  function toPascalSnake(input, options) {
1746
- return convert(input, (key) => ToPascalSnake(key, parseOptions(options).allowSymbols));
273
+ const { keep, ignore } = parseOptions(options);
274
+ return convert(input, (key) => ToPascalSnake(key, keep), ignore);
1747
275
  }
1748
276
  function toPath(input, options) {
1749
- const { allowSymbols, transform, separator } = parseOptions(options);
1750
- return convert(input, (key) => ToPath(key, allowSymbols, transform, separator === "\\" ? "\\" : "/"));
277
+ const { keep, transform, separator, ignore } = parseOptions(options);
278
+ return convert(input, (key) => ToPath(key, keep, transform, separator === "\\" ? "\\" : "/"), ignore);
1751
279
  }
1752
280
  function toSpace(input, options) {
1753
- return convert(input, (key) => ToSpace(key, parseOptions(options).allowSymbols));
281
+ const { keep, ignore } = parseOptions(options);
282
+ return convert(input, (key) => ToSpace(key, keep), ignore);
1754
283
  }
1755
284
  function toLower(input, options) {
1756
- return convert(input, (key) => ToLower(key, parseOptions(options).allowSymbols));
285
+ const { keep, ignore } = parseOptions(options);
286
+ return convert(input, (key) => ToLower(key, keep), ignore);
1757
287
  }
1758
288
  function toUpper(input, options) {
1759
- return convert(input, (key) => ToUpper(key, parseOptions(options).allowSymbols));
289
+ const { keep, ignore } = parseOptions(options);
290
+ return convert(input, (key) => ToUpper(key, keep), ignore);
1760
291
  }
1761
- //#endregion
1762
- 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 };
292
+ export { toCamel, toDot, toKebab, toLower, toPascal, toPascalSnake, toPath, toSentence, toSnake, toSpace, toTitle, toTrain, toUpper, toUpperKebab, toUpperSnake };