caseparser 4.2.0 → 5.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/README.md +103 -13
- package/dist/index.cjs +638 -34
- package/dist/index.d.cts +522 -1
- package/dist/index.d.ts +522 -1
- package/dist/index.js +624 -35
- package/package.json +5 -1
package/dist/index.d.cts
CHANGED
|
@@ -120,6 +120,9 @@ type Result<T, P> = T extends string ? string : T extends Array<unknown> ? { [K
|
|
|
120
120
|
* camelToDash('helloWorld'); // 'hello-world'
|
|
121
121
|
* camelToDash({ firstName: 'John' }); // { 'first-name': 'John' }
|
|
122
122
|
* ```
|
|
123
|
+
*
|
|
124
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
125
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
123
126
|
*/
|
|
124
127
|
export declare function camelToDash<T extends object | string>(input: T): Result<T, "CamelToDash">;
|
|
125
128
|
/**
|
|
@@ -130,6 +133,9 @@ export declare function camelToDash<T extends object | string>(input: T): Result
|
|
|
130
133
|
* camelToSnake('helloWorld'); // 'hello_world'
|
|
131
134
|
* camelToSnake({ firstName: 'John' }); // { first_name: 'John' }
|
|
132
135
|
* ```
|
|
136
|
+
*
|
|
137
|
+
* @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
|
|
138
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
133
139
|
*/
|
|
134
140
|
export declare function camelToSnake<T extends object | string>(input: T): Result<T, "CamelToSnake">;
|
|
135
141
|
/**
|
|
@@ -140,6 +146,9 @@ export declare function camelToSnake<T extends object | string>(input: T): Resul
|
|
|
140
146
|
* camelToPascal('helloWorld'); // 'HelloWorld'
|
|
141
147
|
* camelToPascal({ firstName: 'John' }); // { FirstName: 'John' }
|
|
142
148
|
* ```
|
|
149
|
+
*
|
|
150
|
+
* @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
|
|
151
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
143
152
|
*/
|
|
144
153
|
export declare function camelToPascal<T extends object | string>(input: T): Result<T, "CamelToPascal">;
|
|
145
154
|
/**
|
|
@@ -150,6 +159,9 @@ export declare function camelToPascal<T extends object | string>(input: T): Resu
|
|
|
150
159
|
* camelToUpperSnake('helloWorld'); // 'HELLO_WORLD'
|
|
151
160
|
* camelToUpperSnake({ firstName: 'John' }); // { FIRST_NAME: 'John' }
|
|
152
161
|
* ```
|
|
162
|
+
*
|
|
163
|
+
* @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
|
|
164
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
153
165
|
*/
|
|
154
166
|
export declare function camelToUpperSnake<T extends object | string>(input: T): Result<T, "CamelToUpperSnake">;
|
|
155
167
|
/**
|
|
@@ -160,6 +172,9 @@ export declare function camelToUpperSnake<T extends object | string>(input: T):
|
|
|
160
172
|
* camelToUpperDash('helloWorld'); // 'HELLO-WORLD'
|
|
161
173
|
* camelToUpperDash({ firstName: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
162
174
|
* ```
|
|
175
|
+
*
|
|
176
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
177
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
163
178
|
*/
|
|
164
179
|
export declare function camelToUpperDash<T extends object | string>(input: T): Result<T, "CamelToUpperDash">;
|
|
165
180
|
/**
|
|
@@ -170,6 +185,9 @@ export declare function camelToUpperDash<T extends object | string>(input: T): R
|
|
|
170
185
|
* camelToTrain('helloWorld'); // 'Hello-World'
|
|
171
186
|
* camelToTrain({ firstName: 'John' }); // { 'First-Name': 'John' }
|
|
172
187
|
* ```
|
|
188
|
+
*
|
|
189
|
+
* @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
|
|
190
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
173
191
|
*/
|
|
174
192
|
export declare function camelToTrain<T extends object | string>(input: T): Result<T, "CamelToTrain">;
|
|
175
193
|
/**
|
|
@@ -180,6 +198,9 @@ export declare function camelToTrain<T extends object | string>(input: T): Resul
|
|
|
180
198
|
* camelToDot('helloWorld'); // 'hello.world'
|
|
181
199
|
* camelToDot({ firstName: 'John' }); // { 'first.name': 'John' }
|
|
182
200
|
* ```
|
|
201
|
+
*
|
|
202
|
+
* @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
|
|
203
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
183
204
|
*/
|
|
184
205
|
export declare function camelToDot<T extends object | string>(input: T): Result<T, "CamelToDot">;
|
|
185
206
|
/**
|
|
@@ -190,6 +211,9 @@ export declare function camelToDot<T extends object | string>(input: T): Result<
|
|
|
190
211
|
* camelToTitle('helloWorld'); // 'Hello World'
|
|
191
212
|
* camelToTitle({ firstName: 'John' }); // { 'First Name': 'John' }
|
|
192
213
|
* ```
|
|
214
|
+
*
|
|
215
|
+
* @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
|
|
216
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
193
217
|
*/
|
|
194
218
|
export declare function camelToTitle<T extends object | string>(input: T): Result<T, "CamelToTitle">;
|
|
195
219
|
/**
|
|
@@ -200,6 +224,9 @@ export declare function camelToTitle<T extends object | string>(input: T): Resul
|
|
|
200
224
|
* camelToSentence('helloWorld'); // 'Hello world'
|
|
201
225
|
* camelToSentence({ firstName: 'John' }); // { 'First name': 'John' }
|
|
202
226
|
* ```
|
|
227
|
+
*
|
|
228
|
+
* @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
|
|
229
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
203
230
|
*/
|
|
204
231
|
export declare function camelToSentence<T extends object | string>(input: T): Result<T, "CamelToSentence">;
|
|
205
232
|
//#endregion
|
|
@@ -212,6 +239,9 @@ export declare function camelToSentence<T extends object | string>(input: T): Re
|
|
|
212
239
|
* dashToSnake('hello-world'); // 'hello_world'
|
|
213
240
|
* dashToSnake({ 'first-name': 'John' }); // { first_name: 'John' }
|
|
214
241
|
* ```
|
|
242
|
+
*
|
|
243
|
+
* @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
|
|
244
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
215
245
|
*/
|
|
216
246
|
export declare function dashToSnake<T extends object | string>(input: T): Result<T, "DashToSnake">;
|
|
217
247
|
/**
|
|
@@ -222,6 +252,9 @@ export declare function dashToSnake<T extends object | string>(input: T): Result
|
|
|
222
252
|
* dashToCamel('hello-world'); // 'helloWorld'
|
|
223
253
|
* dashToCamel({ 'first-name': 'John' }); // { firstName: 'John' }
|
|
224
254
|
* ```
|
|
255
|
+
*
|
|
256
|
+
* @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
|
|
257
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
225
258
|
*/
|
|
226
259
|
export declare function dashToCamel<T extends object | string>(input: T): Result<T, "DashToCamel">;
|
|
227
260
|
/**
|
|
@@ -232,6 +265,9 @@ export declare function dashToCamel<T extends object | string>(input: T): Result
|
|
|
232
265
|
* dashToPascal('hello-world'); // 'HelloWorld'
|
|
233
266
|
* dashToPascal({ 'first-name': 'John' }); // { FirstName: 'John' }
|
|
234
267
|
* ```
|
|
268
|
+
*
|
|
269
|
+
* @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
|
|
270
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
235
271
|
*/
|
|
236
272
|
export declare function dashToPascal<T extends object | string>(input: T): Result<T, "DashToPascal">;
|
|
237
273
|
/**
|
|
@@ -242,6 +278,9 @@ export declare function dashToPascal<T extends object | string>(input: T): Resul
|
|
|
242
278
|
* dashToUpperSnake('hello-world'); // 'HELLO_WORLD'
|
|
243
279
|
* dashToUpperSnake({ 'first-name': 'John' }); // { FIRST_NAME: 'John' }
|
|
244
280
|
* ```
|
|
281
|
+
*
|
|
282
|
+
* @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
|
|
283
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
245
284
|
*/
|
|
246
285
|
export declare function dashToUpperSnake<T extends object | string>(input: T): Result<T, "DashToUpperSnake">;
|
|
247
286
|
/**
|
|
@@ -252,6 +291,9 @@ export declare function dashToUpperSnake<T extends object | string>(input: T): R
|
|
|
252
291
|
* dashToUpperDash('hello-world'); // 'HELLO-WORLD'
|
|
253
292
|
* dashToUpperDash({ 'first-name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
254
293
|
* ```
|
|
294
|
+
*
|
|
295
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
296
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
255
297
|
*/
|
|
256
298
|
export declare function dashToUpperDash<T extends object | string>(input: T): Result<T, "DashToUpperDash">;
|
|
257
299
|
/**
|
|
@@ -262,6 +304,9 @@ export declare function dashToUpperDash<T extends object | string>(input: T): Re
|
|
|
262
304
|
* dashToTrain('hello-world'); // 'Hello-World'
|
|
263
305
|
* dashToTrain({ 'first-name': 'John' }); // { 'First-Name': 'John' }
|
|
264
306
|
* ```
|
|
307
|
+
*
|
|
308
|
+
* @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
|
|
309
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
265
310
|
*/
|
|
266
311
|
export declare function dashToTrain<T extends object | string>(input: T): Result<T, "DashToTrain">;
|
|
267
312
|
/**
|
|
@@ -272,6 +317,9 @@ export declare function dashToTrain<T extends object | string>(input: T): Result
|
|
|
272
317
|
* dashToDot('hello-world'); // 'hello.world'
|
|
273
318
|
* dashToDot({ 'first-name': 'John' }); // { 'first.name': 'John' }
|
|
274
319
|
* ```
|
|
320
|
+
*
|
|
321
|
+
* @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
|
|
322
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
275
323
|
*/
|
|
276
324
|
export declare function dashToDot<T extends object | string>(input: T): Result<T, "DashToDot">;
|
|
277
325
|
/**
|
|
@@ -282,6 +330,9 @@ export declare function dashToDot<T extends object | string>(input: T): Result<T
|
|
|
282
330
|
* dashToTitle('hello-world'); // 'Hello World'
|
|
283
331
|
* dashToTitle({ 'first-name': 'John' }); // { 'First Name': 'John' }
|
|
284
332
|
* ```
|
|
333
|
+
*
|
|
334
|
+
* @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
|
|
335
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
285
336
|
*/
|
|
286
337
|
export declare function dashToTitle<T extends object | string>(input: T): Result<T, "DashToTitle">;
|
|
287
338
|
/**
|
|
@@ -292,6 +343,9 @@ export declare function dashToTitle<T extends object | string>(input: T): Result
|
|
|
292
343
|
* dashToSentence('hello-world'); // 'Hello world'
|
|
293
344
|
* dashToSentence({ 'first-name': 'John' }); // { 'First name': 'John' }
|
|
294
345
|
* ```
|
|
346
|
+
*
|
|
347
|
+
* @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
|
|
348
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
295
349
|
*/
|
|
296
350
|
export declare function dashToSentence<T extends object | string>(input: T): Result<T, "DashToSentence">;
|
|
297
351
|
//#endregion
|
|
@@ -304,6 +358,9 @@ export declare function dashToSentence<T extends object | string>(input: T): Res
|
|
|
304
358
|
* pascalToCamel('HelloWorld'); // 'helloWorld'
|
|
305
359
|
* pascalToCamel({ FirstName: 'John' }); // { firstName: 'John' }
|
|
306
360
|
* ```
|
|
361
|
+
*
|
|
362
|
+
* @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
|
|
363
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
307
364
|
*/
|
|
308
365
|
export declare function pascalToCamel<T extends object | string>(input: T): Result<T, "PascalToCamel">;
|
|
309
366
|
/**
|
|
@@ -314,6 +371,9 @@ export declare function pascalToCamel<T extends object | string>(input: T): Resu
|
|
|
314
371
|
* pascalToSnake('HelloWorld'); // 'hello_world'
|
|
315
372
|
* pascalToSnake({ FirstName: 'John' }); // { first_name: 'John' }
|
|
316
373
|
* ```
|
|
374
|
+
*
|
|
375
|
+
* @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
|
|
376
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
317
377
|
*/
|
|
318
378
|
export declare function pascalToSnake<T extends object | string>(input: T): Result<T, "PascalToSnake">;
|
|
319
379
|
/**
|
|
@@ -324,6 +384,9 @@ export declare function pascalToSnake<T extends object | string>(input: T): Resu
|
|
|
324
384
|
* pascalToDash('HelloWorld'); // 'hello-world'
|
|
325
385
|
* pascalToDash({ FirstName: 'John' }); // { 'first-name': 'John' }
|
|
326
386
|
* ```
|
|
387
|
+
*
|
|
388
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
389
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
327
390
|
*/
|
|
328
391
|
export declare function pascalToDash<T extends object | string>(input: T): Result<T, "PascalToDash">;
|
|
329
392
|
/**
|
|
@@ -334,6 +397,9 @@ export declare function pascalToDash<T extends object | string>(input: T): Resul
|
|
|
334
397
|
* pascalToUpperSnake('HelloWorld'); // 'HELLO_WORLD'
|
|
335
398
|
* pascalToUpperSnake({ FirstName: 'John' }); // { FIRST_NAME: 'John' }
|
|
336
399
|
* ```
|
|
400
|
+
*
|
|
401
|
+
* @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
|
|
402
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
337
403
|
*/
|
|
338
404
|
export declare function pascalToUpperSnake<T extends object | string>(input: T): Result<T, "PascalToUpperSnake">;
|
|
339
405
|
/**
|
|
@@ -344,6 +410,9 @@ export declare function pascalToUpperSnake<T extends object | string>(input: T):
|
|
|
344
410
|
* pascalToUpperDash('HelloWorld'); // 'HELLO-WORLD'
|
|
345
411
|
* pascalToUpperDash({ FirstName: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
346
412
|
* ```
|
|
413
|
+
*
|
|
414
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
415
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
347
416
|
*/
|
|
348
417
|
export declare function pascalToUpperDash<T extends object | string>(input: T): Result<T, "PascalToUpperDash">;
|
|
349
418
|
/**
|
|
@@ -354,6 +423,9 @@ export declare function pascalToUpperDash<T extends object | string>(input: T):
|
|
|
354
423
|
* pascalToTrain('HelloWorld'); // 'Hello-World'
|
|
355
424
|
* pascalToTrain({ FirstName: 'John' }); // { 'First-Name': 'John' }
|
|
356
425
|
* ```
|
|
426
|
+
*
|
|
427
|
+
* @deprecated Use `toTrain` 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).
|
|
357
429
|
*/
|
|
358
430
|
export declare function pascalToTrain<T extends object | string>(input: T): Result<T, "PascalToTrain">;
|
|
359
431
|
/**
|
|
@@ -364,6 +436,9 @@ export declare function pascalToTrain<T extends object | string>(input: T): Resu
|
|
|
364
436
|
* pascalToDot('HelloWorld'); // 'hello.world'
|
|
365
437
|
* pascalToDot({ FirstName: 'John' }); // { 'first.name': 'John' }
|
|
366
438
|
* ```
|
|
439
|
+
*
|
|
440
|
+
* @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
|
|
441
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
367
442
|
*/
|
|
368
443
|
export declare function pascalToDot<T extends object | string>(input: T): Result<T, "PascalToDot">;
|
|
369
444
|
/**
|
|
@@ -374,6 +449,9 @@ export declare function pascalToDot<T extends object | string>(input: T): Result
|
|
|
374
449
|
* pascalToTitle('HelloWorld'); // 'Hello World'
|
|
375
450
|
* pascalToTitle({ FirstName: 'John' }); // { 'First Name': 'John' }
|
|
376
451
|
* ```
|
|
452
|
+
*
|
|
453
|
+
* @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
|
|
454
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
377
455
|
*/
|
|
378
456
|
export declare function pascalToTitle<T extends object | string>(input: T): Result<T, "PascalToTitle">;
|
|
379
457
|
/**
|
|
@@ -384,6 +462,9 @@ export declare function pascalToTitle<T extends object | string>(input: T): Resu
|
|
|
384
462
|
* pascalToSentence('HelloWorld'); // 'Hello world'
|
|
385
463
|
* pascalToSentence({ FirstName: 'John' }); // { 'First name': 'John' }
|
|
386
464
|
* ```
|
|
465
|
+
*
|
|
466
|
+
* @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
|
|
467
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
387
468
|
*/
|
|
388
469
|
export declare function pascalToSentence<T extends object | string>(input: T): Result<T, "PascalToSentence">;
|
|
389
470
|
//#endregion
|
|
@@ -396,6 +477,9 @@ export declare function pascalToSentence<T extends object | string>(input: T): R
|
|
|
396
477
|
* snakeToCamel('hello_world'); // 'helloWorld'
|
|
397
478
|
* snakeToCamel({ first_name: 'John' }); // { firstName: 'John' }
|
|
398
479
|
* ```
|
|
480
|
+
*
|
|
481
|
+
* @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
|
|
482
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
399
483
|
*/
|
|
400
484
|
export declare function snakeToCamel<T extends object | string>(input: T): Result<T, "SnakeToCamel">;
|
|
401
485
|
/**
|
|
@@ -406,6 +490,9 @@ export declare function snakeToCamel<T extends object | string>(input: T): Resul
|
|
|
406
490
|
* snakeToDash('hello_world'); // 'hello-world'
|
|
407
491
|
* snakeToDash({ first_name: 'John' }); // { 'first-name': 'John' }
|
|
408
492
|
* ```
|
|
493
|
+
*
|
|
494
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
495
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
409
496
|
*/
|
|
410
497
|
export declare function snakeToDash<T extends object | string>(input: T): Result<T, "SnakeToDash">;
|
|
411
498
|
/**
|
|
@@ -416,6 +503,9 @@ export declare function snakeToDash<T extends object | string>(input: T): Result
|
|
|
416
503
|
* snakeToPascal('hello_world'); // 'HelloWorld'
|
|
417
504
|
* snakeToPascal({ first_name: 'John' }); // { FirstName: 'John' }
|
|
418
505
|
* ```
|
|
506
|
+
*
|
|
507
|
+
* @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
|
|
508
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
419
509
|
*/
|
|
420
510
|
export declare function snakeToPascal<T extends object | string>(input: T): Result<T, "SnakeToPascal">;
|
|
421
511
|
/**
|
|
@@ -426,6 +516,9 @@ export declare function snakeToPascal<T extends object | string>(input: T): Resu
|
|
|
426
516
|
* snakeToUpperSnake('hello_world'); // 'HELLO_WORLD'
|
|
427
517
|
* snakeToUpperSnake({ first_name: 'John' }); // { FIRST_NAME: 'John' }
|
|
428
518
|
* ```
|
|
519
|
+
*
|
|
520
|
+
* @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
|
|
521
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
429
522
|
*/
|
|
430
523
|
export declare function snakeToUpperSnake<T extends object | string>(input: T): Result<T, "SnakeToUpperSnake">;
|
|
431
524
|
/**
|
|
@@ -436,6 +529,9 @@ export declare function snakeToUpperSnake<T extends object | string>(input: T):
|
|
|
436
529
|
* snakeToUpperDash('hello_world'); // 'HELLO-WORLD'
|
|
437
530
|
* snakeToUpperDash({ first_name: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
438
531
|
* ```
|
|
532
|
+
*
|
|
533
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
534
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
439
535
|
*/
|
|
440
536
|
export declare function snakeToUpperDash<T extends object | string>(input: T): Result<T, "SnakeToUpperDash">;
|
|
441
537
|
/**
|
|
@@ -446,6 +542,9 @@ export declare function snakeToUpperDash<T extends object | string>(input: T): R
|
|
|
446
542
|
* snakeToTrain('hello_world'); // 'Hello-World'
|
|
447
543
|
* snakeToTrain({ first_name: 'John' }); // { 'First-Name': 'John' }
|
|
448
544
|
* ```
|
|
545
|
+
*
|
|
546
|
+
* @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
|
|
547
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
449
548
|
*/
|
|
450
549
|
export declare function snakeToTrain<T extends object | string>(input: T): Result<T, "SnakeToTrain">;
|
|
451
550
|
/**
|
|
@@ -456,6 +555,9 @@ export declare function snakeToTrain<T extends object | string>(input: T): Resul
|
|
|
456
555
|
* snakeToDot('hello_world'); // 'hello.world'
|
|
457
556
|
* snakeToDot({ first_name: 'John' }); // { 'first.name': 'John' }
|
|
458
557
|
* ```
|
|
558
|
+
*
|
|
559
|
+
* @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
|
|
560
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
459
561
|
*/
|
|
460
562
|
export declare function snakeToDot<T extends object | string>(input: T): Result<T, "SnakeToDot">;
|
|
461
563
|
/**
|
|
@@ -466,6 +568,9 @@ export declare function snakeToDot<T extends object | string>(input: T): Result<
|
|
|
466
568
|
* snakeToTitle('hello_world'); // 'Hello World'
|
|
467
569
|
* snakeToTitle({ first_name: 'John' }); // { 'First Name': 'John' }
|
|
468
570
|
* ```
|
|
571
|
+
*
|
|
572
|
+
* @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
|
|
573
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
469
574
|
*/
|
|
470
575
|
export declare function snakeToTitle<T extends object | string>(input: T): Result<T, "SnakeToTitle">;
|
|
471
576
|
/**
|
|
@@ -476,6 +581,9 @@ export declare function snakeToTitle<T extends object | string>(input: T): Resul
|
|
|
476
581
|
* snakeToSentence('hello_world'); // 'Hello world'
|
|
477
582
|
* snakeToSentence({ first_name: 'John' }); // { 'First name': 'John' }
|
|
478
583
|
* ```
|
|
584
|
+
*
|
|
585
|
+
* @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
|
|
586
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
479
587
|
*/
|
|
480
588
|
export declare function snakeToSentence<T extends object | string>(input: T): Result<T, "SnakeToSentence">;
|
|
481
589
|
//#endregion
|
|
@@ -488,6 +596,9 @@ export declare function snakeToSentence<T extends object | string>(input: T): Re
|
|
|
488
596
|
* trainToCamel('Hello-World'); // 'helloWorld'
|
|
489
597
|
* trainToCamel({ 'First-Name': 'John' }); // { firstName: 'John' }
|
|
490
598
|
* ```
|
|
599
|
+
*
|
|
600
|
+
* @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
|
|
601
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
491
602
|
*/
|
|
492
603
|
export declare function trainToCamel<T extends object | string>(input: T): Result<T, "TrainToCamel">;
|
|
493
604
|
/**
|
|
@@ -498,6 +609,9 @@ export declare function trainToCamel<T extends object | string>(input: T): Resul
|
|
|
498
609
|
* trainToPascal('Hello-World'); // 'HelloWorld'
|
|
499
610
|
* trainToPascal({ 'First-Name': 'John' }); // { FirstName: 'John' }
|
|
500
611
|
* ```
|
|
612
|
+
*
|
|
613
|
+
* @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
|
|
614
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
501
615
|
*/
|
|
502
616
|
export declare function trainToPascal<T extends object | string>(input: T): Result<T, "TrainToPascal">;
|
|
503
617
|
/**
|
|
@@ -508,6 +622,9 @@ export declare function trainToPascal<T extends object | string>(input: T): Resu
|
|
|
508
622
|
* trainToSnake('Hello-World'); // 'hello_world'
|
|
509
623
|
* trainToSnake({ 'First-Name': 'John' }); // { first_name: 'John' }
|
|
510
624
|
* ```
|
|
625
|
+
*
|
|
626
|
+
* @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
|
|
627
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
511
628
|
*/
|
|
512
629
|
export declare function trainToSnake<T extends object | string>(input: T): Result<T, "TrainToSnake">;
|
|
513
630
|
/**
|
|
@@ -518,6 +635,9 @@ export declare function trainToSnake<T extends object | string>(input: T): Resul
|
|
|
518
635
|
* trainToDash('Hello-World'); // 'hello-world'
|
|
519
636
|
* trainToDash({ 'First-Name': 'John' }); // { 'first-name': 'John' }
|
|
520
637
|
* ```
|
|
638
|
+
*
|
|
639
|
+
* @deprecated Use `toKebab` 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).
|
|
521
641
|
*/
|
|
522
642
|
export declare function trainToDash<T extends object | string>(input: T): Result<T, "TrainToDash">;
|
|
523
643
|
/**
|
|
@@ -528,6 +648,9 @@ export declare function trainToDash<T extends object | string>(input: T): Result
|
|
|
528
648
|
* trainToUpperSnake('Hello-World'); // 'HELLO_WORLD'
|
|
529
649
|
* trainToUpperSnake({ 'First-Name': 'John' }); // { FIRST_NAME: 'John' }
|
|
530
650
|
* ```
|
|
651
|
+
*
|
|
652
|
+
* @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
|
|
653
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
531
654
|
*/
|
|
532
655
|
export declare function trainToUpperSnake<T extends object | string>(input: T): Result<T, "TrainToUpperSnake">;
|
|
533
656
|
/**
|
|
@@ -538,6 +661,9 @@ export declare function trainToUpperSnake<T extends object | string>(input: T):
|
|
|
538
661
|
* trainToUpperDash('Hello-World'); // 'HELLO-WORLD'
|
|
539
662
|
* trainToUpperDash({ 'First-Name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
540
663
|
* ```
|
|
664
|
+
*
|
|
665
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
666
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
541
667
|
*/
|
|
542
668
|
export declare function trainToUpperDash<T extends object | string>(input: T): Result<T, "TrainToUpperDash">;
|
|
543
669
|
/**
|
|
@@ -548,6 +674,9 @@ export declare function trainToUpperDash<T extends object | string>(input: T): R
|
|
|
548
674
|
* trainToDot('Hello-World'); // 'hello.world'
|
|
549
675
|
* trainToDot({ 'First-Name': 'John' }); // { 'first.name': 'John' }
|
|
550
676
|
* ```
|
|
677
|
+
*
|
|
678
|
+
* @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
|
|
679
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
551
680
|
*/
|
|
552
681
|
export declare function trainToDot<T extends object | string>(input: T): Result<T, "TrainToDot">;
|
|
553
682
|
/**
|
|
@@ -558,6 +687,9 @@ export declare function trainToDot<T extends object | string>(input: T): Result<
|
|
|
558
687
|
* trainToTitle('Hello-World'); // 'Hello World'
|
|
559
688
|
* trainToTitle({ 'First-Name': 'John' }); // { 'First Name': 'John' }
|
|
560
689
|
* ```
|
|
690
|
+
*
|
|
691
|
+
* @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
|
|
692
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
561
693
|
*/
|
|
562
694
|
export declare function trainToTitle<T extends object | string>(input: T): Result<T, "TrainToTitle">;
|
|
563
695
|
/**
|
|
@@ -568,6 +700,9 @@ export declare function trainToTitle<T extends object | string>(input: T): Resul
|
|
|
568
700
|
* trainToSentence('Hello-World'); // 'Hello world'
|
|
569
701
|
* trainToSentence({ 'First-Name': 'John' }); // { 'First name': 'John' }
|
|
570
702
|
* ```
|
|
703
|
+
*
|
|
704
|
+
* @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
|
|
705
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
571
706
|
*/
|
|
572
707
|
export declare function trainToSentence<T extends object | string>(input: T): Result<T, "TrainToSentence">;
|
|
573
708
|
//#endregion
|
|
@@ -580,6 +715,9 @@ export declare function trainToSentence<T extends object | string>(input: T): Re
|
|
|
580
715
|
* dotToCamel('hello.world'); // 'helloWorld'
|
|
581
716
|
* dotToCamel({ 'first.name': 'John' }); // { firstName: 'John' }
|
|
582
717
|
* ```
|
|
718
|
+
*
|
|
719
|
+
* @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
|
|
720
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
583
721
|
*/
|
|
584
722
|
export declare function dotToCamel<T extends object | string>(input: T): Result<T, "DotToCamel">;
|
|
585
723
|
/**
|
|
@@ -590,6 +728,9 @@ export declare function dotToCamel<T extends object | string>(input: T): Result<
|
|
|
590
728
|
* dotToPascal('hello.world'); // 'HelloWorld'
|
|
591
729
|
* dotToPascal({ 'first.name': 'John' }); // { FirstName: 'John' }
|
|
592
730
|
* ```
|
|
731
|
+
*
|
|
732
|
+
* @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
|
|
733
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
593
734
|
*/
|
|
594
735
|
export declare function dotToPascal<T extends object | string>(input: T): Result<T, "DotToPascal">;
|
|
595
736
|
/**
|
|
@@ -600,6 +741,9 @@ export declare function dotToPascal<T extends object | string>(input: T): Result
|
|
|
600
741
|
* dotToSnake('hello.world'); // 'hello_world'
|
|
601
742
|
* dotToSnake({ 'first.name': 'John' }); // { first_name: 'John' }
|
|
602
743
|
* ```
|
|
744
|
+
*
|
|
745
|
+
* @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
|
|
746
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
603
747
|
*/
|
|
604
748
|
export declare function dotToSnake<T extends object | string>(input: T): Result<T, "DotToSnake">;
|
|
605
749
|
/**
|
|
@@ -610,6 +754,9 @@ export declare function dotToSnake<T extends object | string>(input: T): Result<
|
|
|
610
754
|
* dotToDash('hello.world'); // 'hello-world'
|
|
611
755
|
* dotToDash({ 'first.name': 'John' }); // { 'first-name': 'John' }
|
|
612
756
|
* ```
|
|
757
|
+
*
|
|
758
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
759
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
613
760
|
*/
|
|
614
761
|
export declare function dotToDash<T extends object | string>(input: T): Result<T, "DotToDash">;
|
|
615
762
|
/**
|
|
@@ -620,6 +767,9 @@ export declare function dotToDash<T extends object | string>(input: T): Result<T
|
|
|
620
767
|
* dotToUpperSnake('hello.world'); // 'HELLO_WORLD'
|
|
621
768
|
* dotToUpperSnake({ 'first.name': 'John' }); // { FIRST_NAME: 'John' }
|
|
622
769
|
* ```
|
|
770
|
+
*
|
|
771
|
+
* @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
|
|
772
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
623
773
|
*/
|
|
624
774
|
export declare function dotToUpperSnake<T extends object | string>(input: T): Result<T, "DotToUpperSnake">;
|
|
625
775
|
/**
|
|
@@ -630,6 +780,9 @@ export declare function dotToUpperSnake<T extends object | string>(input: T): Re
|
|
|
630
780
|
* dotToUpperDash('hello.world'); // 'HELLO-WORLD'
|
|
631
781
|
* dotToUpperDash({ 'first.name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
632
782
|
* ```
|
|
783
|
+
*
|
|
784
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
785
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
633
786
|
*/
|
|
634
787
|
export declare function dotToUpperDash<T extends object | string>(input: T): Result<T, "DotToUpperDash">;
|
|
635
788
|
/**
|
|
@@ -640,6 +793,9 @@ export declare function dotToUpperDash<T extends object | string>(input: T): Res
|
|
|
640
793
|
* dotToTrain('hello.world'); // 'Hello-World'
|
|
641
794
|
* dotToTrain({ 'first.name': 'John' }); // { 'First-Name': 'John' }
|
|
642
795
|
* ```
|
|
796
|
+
*
|
|
797
|
+
* @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
|
|
798
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
643
799
|
*/
|
|
644
800
|
export declare function dotToTrain<T extends object | string>(input: T): Result<T, "DotToTrain">;
|
|
645
801
|
/**
|
|
@@ -650,6 +806,9 @@ export declare function dotToTrain<T extends object | string>(input: T): Result<
|
|
|
650
806
|
* dotToTitle('hello.world'); // 'Hello World'
|
|
651
807
|
* dotToTitle({ 'first.name': 'John' }); // { 'First Name': 'John' }
|
|
652
808
|
* ```
|
|
809
|
+
*
|
|
810
|
+
* @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
|
|
811
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
653
812
|
*/
|
|
654
813
|
export declare function dotToTitle<T extends object | string>(input: T): Result<T, "DotToTitle">;
|
|
655
814
|
/**
|
|
@@ -660,6 +819,9 @@ export declare function dotToTitle<T extends object | string>(input: T): Result<
|
|
|
660
819
|
* dotToSentence('hello.world'); // 'Hello world'
|
|
661
820
|
* dotToSentence({ 'first.name': 'John' }); // { 'First name': 'John' }
|
|
662
821
|
* ```
|
|
822
|
+
*
|
|
823
|
+
* @deprecated Use `toSentence` 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).
|
|
663
825
|
*/
|
|
664
826
|
export declare function dotToSentence<T extends object | string>(input: T): Result<T, "DotToSentence">;
|
|
665
827
|
//#endregion
|
|
@@ -672,6 +834,9 @@ export declare function dotToSentence<T extends object | string>(input: T): Resu
|
|
|
672
834
|
* titleToCamel('Hello World'); // 'helloWorld'
|
|
673
835
|
* titleToCamel({ 'First Name': 'John' }); // { firstName: 'John' }
|
|
674
836
|
* ```
|
|
837
|
+
*
|
|
838
|
+
* @deprecated Use `toCamel` 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).
|
|
675
840
|
*/
|
|
676
841
|
export declare function titleToCamel<T extends object | string>(input: T): Result<T, "TitleToCamel">;
|
|
677
842
|
/**
|
|
@@ -682,6 +847,9 @@ export declare function titleToCamel<T extends object | string>(input: T): Resul
|
|
|
682
847
|
* titleToPascal('Hello World'); // 'HelloWorld'
|
|
683
848
|
* titleToPascal({ 'First Name': 'John' }); // { FirstName: 'John' }
|
|
684
849
|
* ```
|
|
850
|
+
*
|
|
851
|
+
* @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
|
|
852
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
685
853
|
*/
|
|
686
854
|
export declare function titleToPascal<T extends object | string>(input: T): Result<T, "TitleToPascal">;
|
|
687
855
|
/**
|
|
@@ -692,6 +860,9 @@ export declare function titleToPascal<T extends object | string>(input: T): Resu
|
|
|
692
860
|
* titleToSnake('Hello World'); // 'hello_world'
|
|
693
861
|
* titleToSnake({ 'First Name': 'John' }); // { first_name: 'John' }
|
|
694
862
|
* ```
|
|
863
|
+
*
|
|
864
|
+
* @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
|
|
865
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
695
866
|
*/
|
|
696
867
|
export declare function titleToSnake<T extends object | string>(input: T): Result<T, "TitleToSnake">;
|
|
697
868
|
/**
|
|
@@ -702,6 +873,9 @@ export declare function titleToSnake<T extends object | string>(input: T): Resul
|
|
|
702
873
|
* titleToDash('Hello World'); // 'hello-world'
|
|
703
874
|
* titleToDash({ 'First Name': 'John' }); // { 'first-name': 'John' }
|
|
704
875
|
* ```
|
|
876
|
+
*
|
|
877
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
878
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
705
879
|
*/
|
|
706
880
|
export declare function titleToDash<T extends object | string>(input: T): Result<T, "TitleToDash">;
|
|
707
881
|
/**
|
|
@@ -712,6 +886,9 @@ export declare function titleToDash<T extends object | string>(input: T): Result
|
|
|
712
886
|
* titleToUpperSnake('Hello World'); // 'HELLO_WORLD'
|
|
713
887
|
* titleToUpperSnake({ 'First Name': 'John' }); // { FIRST_NAME: 'John' }
|
|
714
888
|
* ```
|
|
889
|
+
*
|
|
890
|
+
* @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
|
|
891
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
715
892
|
*/
|
|
716
893
|
export declare function titleToUpperSnake<T extends object | string>(input: T): Result<T, "TitleToUpperSnake">;
|
|
717
894
|
/**
|
|
@@ -722,6 +899,9 @@ export declare function titleToUpperSnake<T extends object | string>(input: T):
|
|
|
722
899
|
* titleToUpperDash('Hello World'); // 'HELLO-WORLD'
|
|
723
900
|
* titleToUpperDash({ 'First Name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
724
901
|
* ```
|
|
902
|
+
*
|
|
903
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
904
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
725
905
|
*/
|
|
726
906
|
export declare function titleToUpperDash<T extends object | string>(input: T): Result<T, "TitleToUpperDash">;
|
|
727
907
|
/**
|
|
@@ -732,6 +912,9 @@ export declare function titleToUpperDash<T extends object | string>(input: T): R
|
|
|
732
912
|
* titleToTrain('Hello World'); // 'Hello-World'
|
|
733
913
|
* titleToTrain({ 'First Name': 'John' }); // { 'First-Name': 'John' }
|
|
734
914
|
* ```
|
|
915
|
+
*
|
|
916
|
+
* @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
|
|
917
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
735
918
|
*/
|
|
736
919
|
export declare function titleToTrain<T extends object | string>(input: T): Result<T, "TitleToTrain">;
|
|
737
920
|
/**
|
|
@@ -742,6 +925,9 @@ export declare function titleToTrain<T extends object | string>(input: T): Resul
|
|
|
742
925
|
* titleToDot('Hello World'); // 'hello.world'
|
|
743
926
|
* titleToDot({ 'First Name': 'John' }); // { 'first.name': 'John' }
|
|
744
927
|
* ```
|
|
928
|
+
*
|
|
929
|
+
* @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
|
|
930
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
745
931
|
*/
|
|
746
932
|
export declare function titleToDot<T extends object | string>(input: T): Result<T, "TitleToDot">;
|
|
747
933
|
/**
|
|
@@ -752,6 +938,9 @@ export declare function titleToDot<T extends object | string>(input: T): Result<
|
|
|
752
938
|
* titleToSentence('Hello World'); // 'Hello world'
|
|
753
939
|
* titleToSentence({ 'First Name': 'John' }); // { 'First name': 'John' }
|
|
754
940
|
* ```
|
|
941
|
+
*
|
|
942
|
+
* @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
|
|
943
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
755
944
|
*/
|
|
756
945
|
export declare function titleToSentence<T extends object | string>(input: T): Result<T, "TitleToSentence">;
|
|
757
946
|
//#endregion
|
|
@@ -764,6 +953,9 @@ export declare function titleToSentence<T extends object | string>(input: T): Re
|
|
|
764
953
|
* sentenceToCamel('Hello world'); // 'helloWorld'
|
|
765
954
|
* sentenceToCamel({ 'First name': 'John' }); // { firstName: 'John' }
|
|
766
955
|
* ```
|
|
956
|
+
*
|
|
957
|
+
* @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
|
|
958
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
767
959
|
*/
|
|
768
960
|
export declare function sentenceToCamel<T extends object | string>(input: T): Result<T, "SentenceToCamel">;
|
|
769
961
|
/**
|
|
@@ -774,6 +966,9 @@ export declare function sentenceToCamel<T extends object | string>(input: T): Re
|
|
|
774
966
|
* sentenceToPascal('Hello world'); // 'HelloWorld'
|
|
775
967
|
* sentenceToPascal({ 'First name': 'John' }); // { FirstName: 'John' }
|
|
776
968
|
* ```
|
|
969
|
+
*
|
|
970
|
+
* @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
|
|
971
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
777
972
|
*/
|
|
778
973
|
export declare function sentenceToPascal<T extends object | string>(input: T): Result<T, "SentenceToPascal">;
|
|
779
974
|
/**
|
|
@@ -784,6 +979,9 @@ export declare function sentenceToPascal<T extends object | string>(input: T): R
|
|
|
784
979
|
* sentenceToSnake('Hello world'); // 'hello_world'
|
|
785
980
|
* sentenceToSnake({ 'First name': 'John' }); // { first_name: 'John' }
|
|
786
981
|
* ```
|
|
982
|
+
*
|
|
983
|
+
* @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
|
|
984
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
787
985
|
*/
|
|
788
986
|
export declare function sentenceToSnake<T extends object | string>(input: T): Result<T, "SentenceToSnake">;
|
|
789
987
|
/**
|
|
@@ -794,6 +992,9 @@ export declare function sentenceToSnake<T extends object | string>(input: T): Re
|
|
|
794
992
|
* sentenceToDash('Hello world'); // 'hello-world'
|
|
795
993
|
* sentenceToDash({ 'First name': 'John' }); // { 'first-name': 'John' }
|
|
796
994
|
* ```
|
|
995
|
+
*
|
|
996
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
997
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
797
998
|
*/
|
|
798
999
|
export declare function sentenceToDash<T extends object | string>(input: T): Result<T, "SentenceToDash">;
|
|
799
1000
|
/**
|
|
@@ -804,6 +1005,9 @@ export declare function sentenceToDash<T extends object | string>(input: T): Res
|
|
|
804
1005
|
* sentenceToUpperSnake('Hello world'); // 'HELLO_WORLD'
|
|
805
1006
|
* sentenceToUpperSnake({ 'First name': 'John' }); // { FIRST_NAME: 'John' }
|
|
806
1007
|
* ```
|
|
1008
|
+
*
|
|
1009
|
+
* @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
|
|
1010
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
807
1011
|
*/
|
|
808
1012
|
export declare function sentenceToUpperSnake<T extends object | string>(input: T): Result<T, "SentenceToUpperSnake">;
|
|
809
1013
|
/**
|
|
@@ -814,6 +1018,9 @@ export declare function sentenceToUpperSnake<T extends object | string>(input: T
|
|
|
814
1018
|
* sentenceToUpperDash('Hello world'); // 'HELLO-WORLD'
|
|
815
1019
|
* sentenceToUpperDash({ 'First name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
816
1020
|
* ```
|
|
1021
|
+
*
|
|
1022
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1023
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
817
1024
|
*/
|
|
818
1025
|
export declare function sentenceToUpperDash<T extends object | string>(input: T): Result<T, "SentenceToUpperDash">;
|
|
819
1026
|
/**
|
|
@@ -824,6 +1031,9 @@ export declare function sentenceToUpperDash<T extends object | string>(input: T)
|
|
|
824
1031
|
* sentenceToTrain('Hello world'); // 'Hello-World'
|
|
825
1032
|
* sentenceToTrain({ 'First name': 'John' }); // { 'First-Name': 'John' }
|
|
826
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).
|
|
827
1037
|
*/
|
|
828
1038
|
export declare function sentenceToTrain<T extends object | string>(input: T): Result<T, "SentenceToTrain">;
|
|
829
1039
|
/**
|
|
@@ -834,6 +1044,9 @@ export declare function sentenceToTrain<T extends object | string>(input: T): Re
|
|
|
834
1044
|
* sentenceToDot('Hello world'); // 'hello.world'
|
|
835
1045
|
* sentenceToDot({ 'First name': 'John' }); // { 'first.name': 'John' }
|
|
836
1046
|
* ```
|
|
1047
|
+
*
|
|
1048
|
+
* @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
|
|
1049
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
837
1050
|
*/
|
|
838
1051
|
export declare function sentenceToDot<T extends object | string>(input: T): Result<T, "SentenceToDot">;
|
|
839
1052
|
/**
|
|
@@ -844,6 +1057,9 @@ export declare function sentenceToDot<T extends object | string>(input: T): Resu
|
|
|
844
1057
|
* sentenceToTitle('Hello world'); // 'Hello World'
|
|
845
1058
|
* sentenceToTitle({ 'First name': 'John' }); // { 'First Name': 'John' }
|
|
846
1059
|
* ```
|
|
1060
|
+
*
|
|
1061
|
+
* @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
|
|
1062
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
847
1063
|
*/
|
|
848
1064
|
export declare function sentenceToTitle<T extends object | string>(input: T): Result<T, "SentenceToTitle">;
|
|
849
1065
|
//#endregion
|
|
@@ -856,6 +1072,9 @@ export declare function sentenceToTitle<T extends object | string>(input: T): Re
|
|
|
856
1072
|
* upperDashToCamel('HELLO-WORLD'); // 'helloWorld'
|
|
857
1073
|
* upperDashToCamel({ 'FIRST-NAME': 'John' }); // { firstName: 'John' }
|
|
858
1074
|
* ```
|
|
1075
|
+
*
|
|
1076
|
+
* @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
|
|
1077
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
859
1078
|
*/
|
|
860
1079
|
export declare function upperDashToCamel<T extends object | string>(input: T): Result<T, "UpperDashToCamel">;
|
|
861
1080
|
/**
|
|
@@ -866,6 +1085,9 @@ export declare function upperDashToCamel<T extends object | string>(input: T): R
|
|
|
866
1085
|
* upperDashToSnake('HELLO-WORLD'); // 'hello_world'
|
|
867
1086
|
* upperDashToSnake({ 'FIRST-NAME': 'John' }); // { first_name: 'John' }
|
|
868
1087
|
* ```
|
|
1088
|
+
*
|
|
1089
|
+
* @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
|
|
1090
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
869
1091
|
*/
|
|
870
1092
|
export declare function upperDashToSnake<T extends object | string>(input: T): Result<T, "UpperDashToSnake">;
|
|
871
1093
|
/**
|
|
@@ -876,6 +1098,9 @@ export declare function upperDashToSnake<T extends object | string>(input: T): R
|
|
|
876
1098
|
* upperDashToDash('HELLO-WORLD'); // 'hello-world'
|
|
877
1099
|
* upperDashToDash({ 'FIRST-NAME': 'John' }); // { 'first-name': 'John' }
|
|
878
1100
|
* ```
|
|
1101
|
+
*
|
|
1102
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1103
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
879
1104
|
*/
|
|
880
1105
|
export declare function upperDashToDash<T extends object | string>(input: T): Result<T, "UpperDashToDash">;
|
|
881
1106
|
/**
|
|
@@ -886,6 +1111,9 @@ export declare function upperDashToDash<T extends object | string>(input: T): Re
|
|
|
886
1111
|
* upperDashToPascal('HELLO-WORLD'); // 'HelloWorld'
|
|
887
1112
|
* upperDashToPascal({ 'FIRST-NAME': 'John' }); // { FirstName: 'John' }
|
|
888
1113
|
* ```
|
|
1114
|
+
*
|
|
1115
|
+
* @deprecated Use `toPascal` instead, which converts from any case. It keeps acronyms together,
|
|
1116
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
889
1117
|
*/
|
|
890
1118
|
export declare function upperDashToPascal<T extends object | string>(input: T): Result<T, "UpperDashToPascal">;
|
|
891
1119
|
/**
|
|
@@ -896,6 +1124,9 @@ export declare function upperDashToPascal<T extends object | string>(input: T):
|
|
|
896
1124
|
* upperDashToUpperSnake('HELLO-WORLD'); // 'HELLO_WORLD'
|
|
897
1125
|
* upperDashToUpperSnake({ 'FIRST-NAME': 'John' }); // { FIRST_NAME: 'John' }
|
|
898
1126
|
* ```
|
|
1127
|
+
*
|
|
1128
|
+
* @deprecated Use `toUpperSnake` instead, which converts from any case. It keeps acronyms together,
|
|
1129
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
899
1130
|
*/
|
|
900
1131
|
export declare function upperDashToUpperSnake<T extends object | string>(input: T): Result<T, "UpperDashToUpperSnake">;
|
|
901
1132
|
/**
|
|
@@ -906,6 +1137,9 @@ export declare function upperDashToUpperSnake<T extends object | string>(input:
|
|
|
906
1137
|
* upperDashToTrain('HELLO-WORLD'); // 'Hello-World'
|
|
907
1138
|
* upperDashToTrain({ 'FIRST-NAME': 'John' }); // { 'First-Name': 'John' }
|
|
908
1139
|
* ```
|
|
1140
|
+
*
|
|
1141
|
+
* @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
|
|
1142
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
909
1143
|
*/
|
|
910
1144
|
export declare function upperDashToTrain<T extends object | string>(input: T): Result<T, "UpperDashToTrain">;
|
|
911
1145
|
/**
|
|
@@ -916,6 +1150,9 @@ export declare function upperDashToTrain<T extends object | string>(input: T): R
|
|
|
916
1150
|
* upperDashToDot('HELLO-WORLD'); // 'hello.world'
|
|
917
1151
|
* upperDashToDot({ 'FIRST-NAME': 'John' }); // { 'first.name': 'John' }
|
|
918
1152
|
* ```
|
|
1153
|
+
*
|
|
1154
|
+
* @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
|
|
1155
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
919
1156
|
*/
|
|
920
1157
|
export declare function upperDashToDot<T extends object | string>(input: T): Result<T, "UpperDashToDot">;
|
|
921
1158
|
/**
|
|
@@ -926,6 +1163,9 @@ export declare function upperDashToDot<T extends object | string>(input: T): Res
|
|
|
926
1163
|
* upperDashToTitle('HELLO-WORLD'); // 'Hello World'
|
|
927
1164
|
* upperDashToTitle({ 'FIRST-NAME': 'John' }); // { 'First Name': 'John' }
|
|
928
1165
|
* ```
|
|
1166
|
+
*
|
|
1167
|
+
* @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
|
|
1168
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
929
1169
|
*/
|
|
930
1170
|
export declare function upperDashToTitle<T extends object | string>(input: T): Result<T, "UpperDashToTitle">;
|
|
931
1171
|
/**
|
|
@@ -936,6 +1176,9 @@ export declare function upperDashToTitle<T extends object | string>(input: T): R
|
|
|
936
1176
|
* upperDashToSentence('HELLO-WORLD'); // 'Hello world'
|
|
937
1177
|
* upperDashToSentence({ 'FIRST-NAME': 'John' }); // { 'First name': 'John' }
|
|
938
1178
|
* ```
|
|
1179
|
+
*
|
|
1180
|
+
* @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
|
|
1181
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
939
1182
|
*/
|
|
940
1183
|
export declare function upperDashToSentence<T extends object | string>(input: T): Result<T, "UpperDashToSentence">;
|
|
941
1184
|
//#endregion
|
|
@@ -948,6 +1191,9 @@ export declare function upperDashToSentence<T extends object | string>(input: T)
|
|
|
948
1191
|
* upperSnakeToCamel('HELLO_WORLD'); // 'helloWorld'
|
|
949
1192
|
* upperSnakeToCamel({ FIRST_NAME: 'John' }); // { firstName: 'John' }
|
|
950
1193
|
* ```
|
|
1194
|
+
*
|
|
1195
|
+
* @deprecated Use `toCamel` instead, which converts from any case. It keeps acronyms together,
|
|
1196
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
951
1197
|
*/
|
|
952
1198
|
export declare function upperSnakeToCamel<T extends object | string>(input: T): Result<T, "UpperSnakeToCamel">;
|
|
953
1199
|
/**
|
|
@@ -958,6 +1204,9 @@ export declare function upperSnakeToCamel<T extends object | string>(input: T):
|
|
|
958
1204
|
* upperSnakeToSnake('HELLO_WORLD'); // 'hello_world'
|
|
959
1205
|
* upperSnakeToSnake({ FIRST_NAME: 'John' }); // { first_name: 'John' }
|
|
960
1206
|
* ```
|
|
1207
|
+
*
|
|
1208
|
+
* @deprecated Use `toSnake` instead, which converts from any case. It keeps acronyms together,
|
|
1209
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
961
1210
|
*/
|
|
962
1211
|
export declare function upperSnakeToSnake<T extends object | string>(input: T): Result<T, "UpperSnakeToSnake">;
|
|
963
1212
|
/**
|
|
@@ -968,6 +1217,9 @@ export declare function upperSnakeToSnake<T extends object | string>(input: T):
|
|
|
968
1217
|
* upperSnakeToDash('HELLO_WORLD'); // 'hello-world'
|
|
969
1218
|
* upperSnakeToDash({ FIRST_NAME: 'John' }); // { 'first-name': 'John' }
|
|
970
1219
|
* ```
|
|
1220
|
+
*
|
|
1221
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1222
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
971
1223
|
*/
|
|
972
1224
|
export declare function upperSnakeToDash<T extends object | string>(input: T): Result<T, "UpperSnakeToDash">;
|
|
973
1225
|
/**
|
|
@@ -978,6 +1230,9 @@ export declare function upperSnakeToDash<T extends object | string>(input: T): R
|
|
|
978
1230
|
* upperSnakeToPascal('HELLO_WORLD'); // 'HelloWorld'
|
|
979
1231
|
* upperSnakeToPascal({ FIRST_NAME: 'John' }); // { FirstName: 'John' }
|
|
980
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).
|
|
981
1236
|
*/
|
|
982
1237
|
export declare function upperSnakeToPascal<T extends object | string>(input: T): Result<T, "UpperSnakeToPascal">;
|
|
983
1238
|
/**
|
|
@@ -988,6 +1243,9 @@ export declare function upperSnakeToPascal<T extends object | string>(input: T):
|
|
|
988
1243
|
* upperSnakeToUpperDash('HELLO_WORLD'); // 'HELLO-WORLD'
|
|
989
1244
|
* upperSnakeToUpperDash({ FIRST_NAME: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
990
1245
|
* ```
|
|
1246
|
+
*
|
|
1247
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1248
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
991
1249
|
*/
|
|
992
1250
|
export declare function upperSnakeToUpperDash<T extends object | string>(input: T): Result<T, "UpperSnakeToUpperDash">;
|
|
993
1251
|
/**
|
|
@@ -998,6 +1256,9 @@ export declare function upperSnakeToUpperDash<T extends object | string>(input:
|
|
|
998
1256
|
* upperSnakeToTrain('HELLO_WORLD'); // 'Hello-World'
|
|
999
1257
|
* upperSnakeToTrain({ FIRST_NAME: 'John' }); // { 'First-Name': 'John' }
|
|
1000
1258
|
* ```
|
|
1259
|
+
*
|
|
1260
|
+
* @deprecated Use `toTrain` instead, which converts from any case. It keeps acronyms together,
|
|
1261
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1001
1262
|
*/
|
|
1002
1263
|
export declare function upperSnakeToTrain<T extends object | string>(input: T): Result<T, "UpperSnakeToTrain">;
|
|
1003
1264
|
/**
|
|
@@ -1008,6 +1269,9 @@ export declare function upperSnakeToTrain<T extends object | string>(input: T):
|
|
|
1008
1269
|
* upperSnakeToDot('HELLO_WORLD'); // 'hello.world'
|
|
1009
1270
|
* upperSnakeToDot({ FIRST_NAME: 'John' }); // { 'first.name': 'John' }
|
|
1010
1271
|
* ```
|
|
1272
|
+
*
|
|
1273
|
+
* @deprecated Use `toDot` instead, which converts from any case. It keeps acronyms together,
|
|
1274
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1011
1275
|
*/
|
|
1012
1276
|
export declare function upperSnakeToDot<T extends object | string>(input: T): Result<T, "UpperSnakeToDot">;
|
|
1013
1277
|
/**
|
|
@@ -1018,6 +1282,9 @@ export declare function upperSnakeToDot<T extends object | string>(input: T): Re
|
|
|
1018
1282
|
* upperSnakeToTitle('HELLO_WORLD'); // 'Hello World'
|
|
1019
1283
|
* upperSnakeToTitle({ FIRST_NAME: 'John' }); // { 'First Name': 'John' }
|
|
1020
1284
|
* ```
|
|
1285
|
+
*
|
|
1286
|
+
* @deprecated Use `toTitle` instead, which converts from any case. It keeps acronyms together,
|
|
1287
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1021
1288
|
*/
|
|
1022
1289
|
export declare function upperSnakeToTitle<T extends object | string>(input: T): Result<T, "UpperSnakeToTitle">;
|
|
1023
1290
|
/**
|
|
@@ -1028,7 +1295,261 @@ export declare function upperSnakeToTitle<T extends object | string>(input: T):
|
|
|
1028
1295
|
* upperSnakeToSentence('HELLO_WORLD'); // 'Hello world'
|
|
1029
1296
|
* upperSnakeToSentence({ FIRST_NAME: 'John' }); // { 'First name': 'John' }
|
|
1030
1297
|
* ```
|
|
1298
|
+
*
|
|
1299
|
+
* @deprecated Use `toSentence` instead, which converts from any case. It keeps acronyms together,
|
|
1300
|
+
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1031
1301
|
*/
|
|
1032
1302
|
export declare function upperSnakeToSentence<T extends object | string>(input: T): Result<T, "UpperSnakeToSentence">;
|
|
1033
1303
|
//#endregion
|
|
1034
|
-
|
|
1304
|
+
//#region src/anyCase/types.d.ts
|
|
1305
|
+
type Separator = "_" | "-" | "." | " ";
|
|
1306
|
+
/** ASCII punctuation, except the separators `_`, `-` and `.`. */
|
|
1307
|
+
type SymbolChar = "!" | "\"" | "#" | "$" | "%" | "&" | "'" | "(" | ")" | "*" | "+" | "," | "/" | ":" | ";" | "<" | "=" | ">" | "?" | "@" | "[" | "\\" | "]" | "^" | "`" | "{" | "|" | "}" | "~";
|
|
1308
|
+
/**
|
|
1309
|
+
* Which symbols the `toX` functions keep: `true` keeps all of them, `false` (the default)
|
|
1310
|
+
* removes all of them, and an array keeps only the listed ones (e.g. `['$', '@']`).
|
|
1311
|
+
*/
|
|
1312
|
+
type KeepSymbols = boolean | readonly string[];
|
|
1313
|
+
type IsUpper<C extends string> = C extends Lowercase<C> ? false : true;
|
|
1314
|
+
type IsLower<C extends string> = C extends Uppercase<C> ? false : true;
|
|
1315
|
+
type Push<L extends boolean, W extends string[], Word extends string> = Word extends "" ? W : [...W, L extends true ? Lowercase<Word> : Word];
|
|
1316
|
+
type RunText<Run> = Run extends string ? Run : "";
|
|
1317
|
+
/**
|
|
1318
|
+
* Splits a string into lowercase words, the same way `words()` does at runtime:
|
|
1319
|
+
* on `_`, `-`, `.` and spaces, before an uppercase letter that follows a lowercase
|
|
1320
|
+
* letter or a digit (`helloWorld`), and before the last letter of an acronym (`XMLHttp`).
|
|
1321
|
+
* Symbols also start a new word; the ones in `S` are kept (see `words()`). Words are lowercased
|
|
1322
|
+
* unless `L` is `false`. `Run` holds the kept symbols of the current run of symbols, or `false`
|
|
1323
|
+
* outside of one.
|
|
1324
|
+
*/
|
|
1325
|
+
type Words<T extends string, S extends string, L extends boolean = true, W extends string[] = [], Word extends string = "", Prev extends string = "", Run extends string | false = false> = T extends `${infer C}${infer Rest}` ? C extends Separator | SymbolChar ? C extends Separator ? Words<Rest, S, L, Push<L, W, `${Word}${RunText<Run>}`>, "", "", false> : Words<Rest, S, L, W, Word, Prev, `${RunText<Run>}${C extends S ? C : ""}`> : Run extends string ? Words<Rest, S, L, Push<L, W, Word>, `${Run}${C}`, C, false> : IsUpper<C> extends true ? Prev extends "" ? Words<Rest, S, L, W, `${Word}${C}`, C> : IsUpper<Prev> extends false ? Words<Rest, S, L, Push<L, W, Word>, C, C> : Rest extends `${infer Next}${string}` ? IsLower<Next> extends true ? Words<Rest, S, L, Push<L, W, Word>, C, C> : Words<Rest, S, L, W, `${Word}${C}`, C> : Words<Rest, S, L, W, `${Word}${C}`, C> : Words<Rest, S, L, W, `${Word}${C}`, C> : Push<L, W, `${Word}${RunText<Run>}`>;
|
|
1326
|
+
/** Uppercases the first character that is not a symbol: `'$id'` → `'$Id'`. */
|
|
1327
|
+
type CapitalizeWord<W> = W extends `${infer C}${infer R}` ? C extends SymbolChar ? `${C}${CapitalizeWord<R>}` : `${Uppercase<C>}${R}` : W;
|
|
1328
|
+
type Join<W, S extends string> = W extends [infer A] ? A & string : W extends [infer A, ...infer R] ? `${A & string}${S}${Join<R, S>}` : "";
|
|
1329
|
+
type CapitalizeAll<W> = { [K in keyof W]: CapitalizeWord<W[K] & string>; };
|
|
1330
|
+
type CamelWords<W> = W extends [infer F, ...infer R] ? `${F & string}${Join<CapitalizeAll<R>, "">}` : "";
|
|
1331
|
+
/** A case that the `toX` functions (e.g. `toSnake`) convert to. */
|
|
1332
|
+
type Case = "Camel" | "Pascal" | "Snake" | "Kebab" | "UpperSnake" | "UpperKebab" | "Train" | "Dot" | "Title" | "Sentence" | "PascalSnake" | "Path" | "Space" | "Lower" | "Upper";
|
|
1333
|
+
/** The symbols kept by a `keepSymbols` argument: `true` → all, `false` → none, `'$' | '@'` → those. */
|
|
1334
|
+
type KeptSymbols<S> = S extends true ? SymbolChar : S extends false ? never : S & string;
|
|
1335
|
+
type ConvertKey<K extends string, C extends Case, S extends string> = string extends K ? string : C extends "Camel" ? CamelWords<Words<K, S>> : C extends "Pascal" ? Join<CapitalizeAll<Words<K, S>>, ""> : C extends "Snake" ? Join<Words<K, S>, "_"> : C extends "Kebab" ? Join<Words<K, S>, "-"> : C extends "UpperSnake" ? Uppercase<Join<Words<K, S>, "_">> : C extends "UpperKebab" ? Uppercase<Join<Words<K, S>, "-">> : C extends "Train" ? Join<CapitalizeAll<Words<K, S>>, "-"> : C extends "Dot" ? Join<Words<K, S, false>, "."> : C extends "Title" ? Join<CapitalizeAll<Words<K, S>>, " "> : C extends "Sentence" ? CapitalizeWord<Join<Words<K, S>, " ">> : C extends "PascalSnake" ? Join<CapitalizeAll<Words<K, S>>, "_"> : C extends "Path" ? Join<Words<K, S, false>, "/"> : C extends "Space" ? Join<Words<K, S, false>, " "> : C extends "Lower" ? Join<Words<K, S>, " "> : C extends "Upper" ? Uppercase<Join<Words<K, S>, " ">> : never;
|
|
1336
|
+
/**
|
|
1337
|
+
* The type returned by a `toX` function: strings stay `string`, and object keys
|
|
1338
|
+
* in any case (deeply, including inside arrays) are renamed to the case `C`.
|
|
1339
|
+
* `S` is the `keepSymbols` argument (`false` by default).
|
|
1340
|
+
*/
|
|
1341
|
+
type CaseResult<T, C extends Case, S = false> = T extends string ? string : T extends Array<unknown> ? { [K in keyof T]: CaseResult<T[K], C, S>; } : T extends object ? Prettify<{ [K in keyof T as boolean extends S ? string : string extends KeptSymbols<S> ? string : ConvertKey<K & string, C, KeptSymbols<S>>]: CaseResult<T[K], C, S>; }> : T;
|
|
1342
|
+
//#endregion
|
|
1343
|
+
//#region src/anyCase/anyCase.d.ts
|
|
1344
|
+
/**
|
|
1345
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to camelCase.
|
|
1346
|
+
*
|
|
1347
|
+
* @example
|
|
1348
|
+
* ```ts
|
|
1349
|
+
* toCamel('hello_world'); // 'helloWorld'
|
|
1350
|
+
* toCamel({ first_name: 'John', userID: 1 }); // { firstName: 'John', userId: 1 }
|
|
1351
|
+
* toCamel('$hello-world', true); // '$helloWorld'
|
|
1352
|
+
* ```
|
|
1353
|
+
*
|
|
1354
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1355
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1356
|
+
*/
|
|
1357
|
+
export declare function toCamel<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Camel", S>;
|
|
1358
|
+
/**
|
|
1359
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to PascalCase.
|
|
1360
|
+
*
|
|
1361
|
+
* @example
|
|
1362
|
+
* ```ts
|
|
1363
|
+
* toPascal('hello-world'); // 'HelloWorld'
|
|
1364
|
+
* toPascal({ 'first-name': 'John', userID: 1 }); // { FirstName: 'John', UserId: 1 }
|
|
1365
|
+
* toPascal('$hello-world', true); // '$HelloWorld'
|
|
1366
|
+
* ```
|
|
1367
|
+
*
|
|
1368
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1369
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1370
|
+
*/
|
|
1371
|
+
export declare function toPascal<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Pascal", S>;
|
|
1372
|
+
/**
|
|
1373
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to snake_case.
|
|
1374
|
+
*
|
|
1375
|
+
* @example
|
|
1376
|
+
* ```ts
|
|
1377
|
+
* toSnake('helloWorld'); // 'hello_world'
|
|
1378
|
+
* toSnake({ firstName: 'John', userID: 1 }); // { first_name: 'John', user_id: 1 }
|
|
1379
|
+
* toSnake('$hello-world', true); // '$hello_world'
|
|
1380
|
+
* ```
|
|
1381
|
+
*
|
|
1382
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1383
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1384
|
+
*/
|
|
1385
|
+
export declare function toSnake<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Snake", S>;
|
|
1386
|
+
/**
|
|
1387
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to kebab-case.
|
|
1388
|
+
*
|
|
1389
|
+
* @example
|
|
1390
|
+
* ```ts
|
|
1391
|
+
* toKebab('HELLO_WORLD'); // 'hello-world'
|
|
1392
|
+
* toKebab({ FIRST_NAME: 'John', userID: 1 }); // { 'first-name': 'John', 'user-id': 1 }
|
|
1393
|
+
* toKebab('$hello-world', true); // '$hello-world'
|
|
1394
|
+
* ```
|
|
1395
|
+
*
|
|
1396
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1397
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1398
|
+
*/
|
|
1399
|
+
export declare function toKebab<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Kebab", S>;
|
|
1400
|
+
/**
|
|
1401
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to UPPER_SNAKE_CASE.
|
|
1402
|
+
*
|
|
1403
|
+
* @example
|
|
1404
|
+
* ```ts
|
|
1405
|
+
* toUpperSnake('hello-world'); // 'HELLO_WORLD'
|
|
1406
|
+
* toUpperSnake({ 'first-name': 'John', userID: 1 }); // { FIRST_NAME: 'John', USER_ID: 1 }
|
|
1407
|
+
* toUpperSnake('$hello-world', true); // '$HELLO_WORLD'
|
|
1408
|
+
* ```
|
|
1409
|
+
*
|
|
1410
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1411
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1412
|
+
*/
|
|
1413
|
+
export declare function toUpperSnake<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "UpperSnake", S>;
|
|
1414
|
+
/**
|
|
1415
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to UPPER-KEBAB-CASE.
|
|
1416
|
+
*
|
|
1417
|
+
* @example
|
|
1418
|
+
* ```ts
|
|
1419
|
+
* toUpperKebab('helloWorld'); // 'HELLO-WORLD'
|
|
1420
|
+
* toUpperKebab({ firstName: 'John', userID: 1 }); // { 'FIRST-NAME': 'John', 'USER-ID': 1 }
|
|
1421
|
+
* toUpperKebab('$hello-world', true); // '$HELLO-WORLD'
|
|
1422
|
+
* ```
|
|
1423
|
+
*
|
|
1424
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1425
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1426
|
+
*/
|
|
1427
|
+
export declare function toUpperKebab<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "UpperKebab", S>;
|
|
1428
|
+
/**
|
|
1429
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to Train-Case.
|
|
1430
|
+
*
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```ts
|
|
1433
|
+
* toTrain('hello_world'); // 'Hello-World'
|
|
1434
|
+
* toTrain({ first_name: 'John', userID: 1 }); // { 'First-Name': 'John', 'User-Id': 1 }
|
|
1435
|
+
* toTrain('$hello-world', true); // '$Hello-World'
|
|
1436
|
+
* ```
|
|
1437
|
+
*
|
|
1438
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1439
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1440
|
+
*/
|
|
1441
|
+
export declare function toTrain<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Train", S>;
|
|
1442
|
+
/**
|
|
1443
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to dot.case, keeping the original case of each word.
|
|
1444
|
+
*
|
|
1445
|
+
* @example
|
|
1446
|
+
* ```ts
|
|
1447
|
+
* toDot('HelloWorld'); // 'Hello.World'
|
|
1448
|
+
* toDot({ FirstName: 'John', userID: 1 }); // { 'First.Name': 'John', 'user.ID': 1 }
|
|
1449
|
+
* toDot('$hello-world', true); // '$hello.world'
|
|
1450
|
+
* ```
|
|
1451
|
+
*
|
|
1452
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1453
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1454
|
+
*/
|
|
1455
|
+
export declare function toDot<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Dot", S>;
|
|
1456
|
+
/**
|
|
1457
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to Title Case.
|
|
1458
|
+
*
|
|
1459
|
+
* @example
|
|
1460
|
+
* ```ts
|
|
1461
|
+
* toTitle('hello_world'); // 'Hello World'
|
|
1462
|
+
* toTitle({ first_name: 'John', userID: 1 }); // { 'First Name': 'John', 'User Id': 1 }
|
|
1463
|
+
* toTitle('$hello-world', true); // '$Hello World'
|
|
1464
|
+
* ```
|
|
1465
|
+
*
|
|
1466
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1467
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1468
|
+
*/
|
|
1469
|
+
export declare function toTitle<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Title", S>;
|
|
1470
|
+
/**
|
|
1471
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to Sentence case.
|
|
1472
|
+
*
|
|
1473
|
+
* @example
|
|
1474
|
+
* ```ts
|
|
1475
|
+
* toSentence('helloWorld'); // 'Hello world'
|
|
1476
|
+
* toSentence({ firstName: 'John', userID: 1 }); // { 'First name': 'John', 'User id': 1 }
|
|
1477
|
+
* toSentence('$hello-world', true); // '$Hello world'
|
|
1478
|
+
* ```
|
|
1479
|
+
*
|
|
1480
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1481
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1482
|
+
*/
|
|
1483
|
+
export declare function toSentence<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Sentence", S>;
|
|
1484
|
+
/**
|
|
1485
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to Pascal_Snake_Case (also known as Ada_Case).
|
|
1486
|
+
*
|
|
1487
|
+
* @example
|
|
1488
|
+
* ```ts
|
|
1489
|
+
* toPascalSnake('helloWorld'); // 'Hello_World'
|
|
1490
|
+
* toPascalSnake({ first_name: 'John', userID: 1 }); // { First_Name: 'John', User_Id: 1 }
|
|
1491
|
+
* toPascalSnake('$hello-world', true); // '$Hello_World'
|
|
1492
|
+
* ```
|
|
1493
|
+
*
|
|
1494
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1495
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1496
|
+
*/
|
|
1497
|
+
export declare function toPascalSnake<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "PascalSnake", S>;
|
|
1498
|
+
/**
|
|
1499
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to path/case, keeping the original case of each word.
|
|
1500
|
+
*
|
|
1501
|
+
* @example
|
|
1502
|
+
* ```ts
|
|
1503
|
+
* toPath('helloWorld'); // 'hello/World'
|
|
1504
|
+
* toPath({ first_name: 'John', userID: 1 }); // { 'first/name': 'John', 'user/ID': 1 }
|
|
1505
|
+
* toPath('$hello-world', true); // '$hello/world'
|
|
1506
|
+
* ```
|
|
1507
|
+
*
|
|
1508
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1509
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1510
|
+
*/
|
|
1511
|
+
export declare function toPath<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Path", S>;
|
|
1512
|
+
/**
|
|
1513
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to space case, keeping the original case of each word.
|
|
1514
|
+
*
|
|
1515
|
+
* @example
|
|
1516
|
+
* ```ts
|
|
1517
|
+
* toSpace('helloWorld'); // 'hello World'
|
|
1518
|
+
* toSpace({ first_name: 'John', userID: 1 }); // { 'first name': 'John', 'user ID': 1 }
|
|
1519
|
+
* toSpace('$hello-world', true); // '$hello world'
|
|
1520
|
+
* ```
|
|
1521
|
+
*
|
|
1522
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1523
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1524
|
+
*/
|
|
1525
|
+
export declare function toSpace<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Space", S>;
|
|
1526
|
+
/**
|
|
1527
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to lower case (space separated).
|
|
1528
|
+
*
|
|
1529
|
+
* @example
|
|
1530
|
+
* ```ts
|
|
1531
|
+
* toLower('helloWorld'); // 'hello world'
|
|
1532
|
+
* toLower({ first_name: 'John', userID: 1 }); // { 'first name': 'John', 'user id': 1 }
|
|
1533
|
+
* toLower('$hello-world', true); // '$hello world'
|
|
1534
|
+
* ```
|
|
1535
|
+
*
|
|
1536
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1537
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1538
|
+
*/
|
|
1539
|
+
export declare function toLower<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Lower", S>;
|
|
1540
|
+
/**
|
|
1541
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to UPPER CASE (space separated).
|
|
1542
|
+
*
|
|
1543
|
+
* @example
|
|
1544
|
+
* ```ts
|
|
1545
|
+
* toUpper('helloWorld'); // 'HELLO WORLD'
|
|
1546
|
+
* toUpper({ first_name: 'John', userID: 1 }); // { 'FIRST NAME': 'John', 'USER ID': 1 }
|
|
1547
|
+
* toUpper('$hello-world', true); // '$HELLO WORLD'
|
|
1548
|
+
* ```
|
|
1549
|
+
*
|
|
1550
|
+
* @param keepSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1551
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1552
|
+
*/
|
|
1553
|
+
export declare function toUpper<T extends object | string, S extends boolean | string = false>(input: T, keepSymbols?: S | readonly S[]): CaseResult<T, "Upper", S>;
|
|
1554
|
+
//#endregion
|
|
1555
|
+
export type { Case, CaseResult, KeepSymbols, ParserType, Prettify, Result };
|