caseparser 4.0.0 → 4.1.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 +70 -142
- package/dist/index.cjs +395 -1
- package/dist/index.d.cts +300 -8
- package/dist/index.d.ts +300 -8
- package/dist/index.js +370 -2
- package/package.json +15 -7
package/dist/index.js
CHANGED
|
@@ -27,31 +27,57 @@ const CamelToPascal = (str) => Capitalize(str);
|
|
|
27
27
|
const CamelToSnake = (str) => str.replace(/([A-Z])/g, (g) => "_" + g[0].toLowerCase());
|
|
28
28
|
const CamelToUpperDash = (str) => Uppercase(CamelToDash(str));
|
|
29
29
|
const CamelToUpperSnake = (str) => Uppercase(CamelToSnake(str));
|
|
30
|
+
const CamelToTrain = (str) => DashToTrain(CamelToDash(str));
|
|
31
|
+
const CamelToDot = (str) => DashToDot(CamelToDash(str));
|
|
30
32
|
const DashToCamel = (str) => str.replace(/(\-\w)/g, (g) => g[1].toUpperCase());
|
|
31
33
|
const DashToPascal = (str) => Capitalize(DashToCamel(str));
|
|
32
34
|
const DashToSnake = (str) => str.replace(/(\-)/g, "_");
|
|
33
35
|
const DashToUpperDash = (str) => Uppercase(str);
|
|
34
36
|
const DashToUpperSnake = (str) => Uppercase(DashToSnake(str));
|
|
37
|
+
const DashToTrain = (str) => str.split("-").map(Capitalize).join("-");
|
|
38
|
+
const DashToDot = (str) => str.replace(/(\-)/g, ".");
|
|
35
39
|
const PascalToCamel = (str) => Uncapitalize(str);
|
|
36
40
|
const PascalToDash = (str) => CamelToDash(Uncapitalize(str));
|
|
37
41
|
const PascalToSnake = (str) => CamelToSnake(Uncapitalize(str));
|
|
38
42
|
const PascalToUpperDash = (str) => Uppercase(PascalToDash(str));
|
|
39
43
|
const PascalToUpperSnake = (str) => Uppercase(PascalToSnake(str));
|
|
44
|
+
const PascalToTrain = (str) => DashToTrain(PascalToDash(str));
|
|
45
|
+
const PascalToDot = (str) => DashToDot(PascalToDash(str));
|
|
40
46
|
const SnakeToCamel = (str) => str.replace(/(\_\w)/g, (g) => g[1].toUpperCase());
|
|
41
47
|
const SnakeToDash = (str) => str.replace(/(\_)/g, "-");
|
|
42
48
|
const SnakeToPascal = (str) => Capitalize(SnakeToCamel(str));
|
|
43
49
|
const SnakeToUpperDash = (str) => Uppercase(SnakeToDash(str));
|
|
50
|
+
const SnakeToTrain = (str) => DashToTrain(SnakeToDash(str));
|
|
51
|
+
const SnakeToDot = (str) => DashToDot(SnakeToDash(str));
|
|
44
52
|
const SnakeToUpperSnake = (str) => Uppercase(str);
|
|
45
53
|
const UpperDashToCamel = (str) => DashToCamel(Lowercase(str));
|
|
46
54
|
const UpperDashToDash = (str) => Lowercase(str);
|
|
47
55
|
const UpperDashToPascal = (str) => Capitalize(UpperDashToCamel(str));
|
|
48
56
|
const UpperDashToSnake = (str) => DashToSnake(UpperDashToDash(str));
|
|
49
57
|
const UpperDashToUpperSnake = (str) => Uppercase(UpperDashToSnake(str));
|
|
58
|
+
const UpperDashToTrain = (str) => DashToTrain(UpperDashToDash(str));
|
|
59
|
+
const UpperDashToDot = (str) => DashToDot(UpperDashToDash(str));
|
|
50
60
|
const UpperSnakeToCamel = (str) => SnakeToCamel(Lowercase(str));
|
|
51
61
|
const UpperSnakeToDash = (str) => str.replace(/(\_)/g, "-").toLowerCase();
|
|
52
62
|
const UpperSnakeToPascal = (str) => SnakeToPascal(Lowercase(str));
|
|
53
63
|
const UpperSnakeToSnake = (str) => Lowercase(str);
|
|
54
64
|
const UpperSnakeToUpperDash = (str) => Uppercase(UpperSnakeToDash(str));
|
|
65
|
+
const UpperSnakeToTrain = (str) => DashToTrain(UpperSnakeToDash(str));
|
|
66
|
+
const UpperSnakeToDot = (str) => DashToDot(UpperSnakeToDash(str));
|
|
67
|
+
const TrainToCamel = (str) => DashToCamel(TrainToDash(str));
|
|
68
|
+
const TrainToDash = (str) => Lowercase(str);
|
|
69
|
+
const TrainToDot = (str) => DashToDot(TrainToDash(str));
|
|
70
|
+
const TrainToPascal = (str) => DashToPascal(TrainToDash(str));
|
|
71
|
+
const TrainToSnake = (str) => DashToSnake(TrainToDash(str));
|
|
72
|
+
const TrainToUpperDash = (str) => Uppercase(str);
|
|
73
|
+
const TrainToUpperSnake = (str) => DashToUpperSnake(TrainToDash(str));
|
|
74
|
+
const DotToCamel = (str) => DashToCamel(DotToDash(str));
|
|
75
|
+
const DotToDash = (str) => str.replace(/(\.)/g, "-");
|
|
76
|
+
const DotToPascal = (str) => DashToPascal(DotToDash(str));
|
|
77
|
+
const DotToSnake = (str) => DashToSnake(DotToDash(str));
|
|
78
|
+
const DotToTrain = (str) => DashToTrain(DotToDash(str));
|
|
79
|
+
const DotToUpperDash = (str) => Uppercase(DotToDash(str));
|
|
80
|
+
const DotToUpperSnake = (str) => DashToUpperSnake(DotToDash(str));
|
|
55
81
|
function parse(input, type) {
|
|
56
82
|
return {
|
|
57
83
|
CamelToDash,
|
|
@@ -83,7 +109,33 @@ function parse(input, type) {
|
|
|
83
109
|
UpperDashToSnake,
|
|
84
110
|
UpperDashToDash,
|
|
85
111
|
UpperDashToPascal,
|
|
86
|
-
UpperDashToUpperSnake
|
|
112
|
+
UpperDashToUpperSnake,
|
|
113
|
+
CamelToTrain,
|
|
114
|
+
CamelToDot,
|
|
115
|
+
PascalToTrain,
|
|
116
|
+
PascalToDot,
|
|
117
|
+
SnakeToTrain,
|
|
118
|
+
SnakeToDot,
|
|
119
|
+
DashToTrain,
|
|
120
|
+
DashToDot,
|
|
121
|
+
UpperSnakeToTrain,
|
|
122
|
+
UpperSnakeToDot,
|
|
123
|
+
UpperDashToTrain,
|
|
124
|
+
UpperDashToDot,
|
|
125
|
+
TrainToCamel,
|
|
126
|
+
TrainToPascal,
|
|
127
|
+
TrainToSnake,
|
|
128
|
+
TrainToDash,
|
|
129
|
+
TrainToUpperSnake,
|
|
130
|
+
TrainToUpperDash,
|
|
131
|
+
TrainToDot,
|
|
132
|
+
DotToCamel,
|
|
133
|
+
DotToPascal,
|
|
134
|
+
DotToSnake,
|
|
135
|
+
DotToDash,
|
|
136
|
+
DotToUpperSnake,
|
|
137
|
+
DotToUpperDash,
|
|
138
|
+
DotToTrain
|
|
87
139
|
}[type](input);
|
|
88
140
|
}
|
|
89
141
|
//#endregion
|
|
@@ -186,6 +238,30 @@ function camelToUpperSnake(input) {
|
|
|
186
238
|
function camelToUpperDash(input) {
|
|
187
239
|
return converter(input, "CamelToUpperDash");
|
|
188
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to Train-Case.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* camelToTrain('helloWorld'); // 'Hello-World'
|
|
247
|
+
* camelToTrain({ firstName: 'John' }); // { 'First-Name': 'John' }
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
function camelToTrain(input) {
|
|
251
|
+
return converter(input, "CamelToTrain");
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to dot.case.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* camelToDot('helloWorld'); // 'hello.world'
|
|
259
|
+
* camelToDot({ firstName: 'John' }); // { 'first.name': 'John' }
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
function camelToDot(input) {
|
|
263
|
+
return converter(input, "CamelToDot");
|
|
264
|
+
}
|
|
189
265
|
//#endregion
|
|
190
266
|
//#region src/dashCase/dashCase.ts
|
|
191
267
|
/**
|
|
@@ -248,6 +324,30 @@ function dashToUpperSnake(input) {
|
|
|
248
324
|
function dashToUpperDash(input) {
|
|
249
325
|
return converter(input, "DashToUpperDash");
|
|
250
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to Train-Case.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* dashToTrain('hello-world'); // 'Hello-World'
|
|
333
|
+
* dashToTrain({ 'first-name': 'John' }); // { 'First-Name': 'John' }
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
function dashToTrain(input) {
|
|
337
|
+
return converter(input, "DashToTrain");
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to dot.case.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```ts
|
|
344
|
+
* dashToDot('hello-world'); // 'hello.world'
|
|
345
|
+
* dashToDot({ 'first-name': 'John' }); // { 'first.name': 'John' }
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
function dashToDot(input) {
|
|
349
|
+
return converter(input, "DashToDot");
|
|
350
|
+
}
|
|
251
351
|
//#endregion
|
|
252
352
|
//#region src/pascalCase/pascalCase.ts
|
|
253
353
|
/**
|
|
@@ -310,6 +410,30 @@ function pascalToUpperSnake(input) {
|
|
|
310
410
|
function pascalToUpperDash(input) {
|
|
311
411
|
return converter(input, "PascalToUpperDash");
|
|
312
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to Train-Case.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```ts
|
|
418
|
+
* pascalToTrain('HelloWorld'); // 'Hello-World'
|
|
419
|
+
* pascalToTrain({ FirstName: 'John' }); // { 'First-Name': 'John' }
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
function pascalToTrain(input) {
|
|
423
|
+
return converter(input, "PascalToTrain");
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to dot.case.
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```ts
|
|
430
|
+
* pascalToDot('HelloWorld'); // 'hello.world'
|
|
431
|
+
* pascalToDot({ FirstName: 'John' }); // { 'first.name': 'John' }
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
function pascalToDot(input) {
|
|
435
|
+
return converter(input, "PascalToDot");
|
|
436
|
+
}
|
|
313
437
|
//#endregion
|
|
314
438
|
//#region src/snakeCase/snakeCase.ts
|
|
315
439
|
/**
|
|
@@ -372,6 +496,202 @@ function snakeToUpperSnake(input) {
|
|
|
372
496
|
function snakeToUpperDash(input) {
|
|
373
497
|
return converter(input, "SnakeToUpperDash");
|
|
374
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to Train-Case.
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* ```ts
|
|
504
|
+
* snakeToTrain('hello_world'); // 'Hello-World'
|
|
505
|
+
* snakeToTrain({ first_name: 'John' }); // { 'First-Name': 'John' }
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
function snakeToTrain(input) {
|
|
509
|
+
return converter(input, "SnakeToTrain");
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to dot.case.
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```ts
|
|
516
|
+
* snakeToDot('hello_world'); // 'hello.world'
|
|
517
|
+
* snakeToDot({ first_name: 'John' }); // { 'first.name': 'John' }
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
520
|
+
function snakeToDot(input) {
|
|
521
|
+
return converter(input, "SnakeToDot");
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/trainCase/trainCase.ts
|
|
525
|
+
/**
|
|
526
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to camelCase.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* ```ts
|
|
530
|
+
* trainToCamel('Hello-World'); // 'helloWorld'
|
|
531
|
+
* trainToCamel({ 'First-Name': 'John' }); // { firstName: 'John' }
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
function trainToCamel(input) {
|
|
535
|
+
return converter(input, "TrainToCamel");
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to PascalCase.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```ts
|
|
542
|
+
* trainToPascal('Hello-World'); // 'HelloWorld'
|
|
543
|
+
* trainToPascal({ 'First-Name': 'John' }); // { FirstName: 'John' }
|
|
544
|
+
* ```
|
|
545
|
+
*/
|
|
546
|
+
function trainToPascal(input) {
|
|
547
|
+
return converter(input, "TrainToPascal");
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to snake_case.
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* ```ts
|
|
554
|
+
* trainToSnake('Hello-World'); // 'hello_world'
|
|
555
|
+
* trainToSnake({ 'First-Name': 'John' }); // { first_name: 'John' }
|
|
556
|
+
* ```
|
|
557
|
+
*/
|
|
558
|
+
function trainToSnake(input) {
|
|
559
|
+
return converter(input, "TrainToSnake");
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to dash-case.
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* ```ts
|
|
566
|
+
* trainToDash('Hello-World'); // 'hello-world'
|
|
567
|
+
* trainToDash({ 'First-Name': 'John' }); // { 'first-name': 'John' }
|
|
568
|
+
* ```
|
|
569
|
+
*/
|
|
570
|
+
function trainToDash(input) {
|
|
571
|
+
return converter(input, "TrainToDash");
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to UPPER_SNAKE_CASE.
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* ```ts
|
|
578
|
+
* trainToUpperSnake('Hello-World'); // 'HELLO_WORLD'
|
|
579
|
+
* trainToUpperSnake({ 'First-Name': 'John' }); // { FIRST_NAME: 'John' }
|
|
580
|
+
* ```
|
|
581
|
+
*/
|
|
582
|
+
function trainToUpperSnake(input) {
|
|
583
|
+
return converter(input, "TrainToUpperSnake");
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to UPPER-DASH-CASE.
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* ```ts
|
|
590
|
+
* trainToUpperDash('Hello-World'); // 'HELLO-WORLD'
|
|
591
|
+
* trainToUpperDash({ 'First-Name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
function trainToUpperDash(input) {
|
|
595
|
+
return converter(input, "TrainToUpperDash");
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to dot.case.
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```ts
|
|
602
|
+
* trainToDot('Hello-World'); // 'hello.world'
|
|
603
|
+
* trainToDot({ 'First-Name': 'John' }); // { 'first.name': 'John' }
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
function trainToDot(input) {
|
|
607
|
+
return converter(input, "TrainToDot");
|
|
608
|
+
}
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/dotCase/dotCase.ts
|
|
611
|
+
/**
|
|
612
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to camelCase.
|
|
613
|
+
*
|
|
614
|
+
* @example
|
|
615
|
+
* ```ts
|
|
616
|
+
* dotToCamel('hello.world'); // 'helloWorld'
|
|
617
|
+
* dotToCamel({ 'first.name': 'John' }); // { firstName: 'John' }
|
|
618
|
+
* ```
|
|
619
|
+
*/
|
|
620
|
+
function dotToCamel(input) {
|
|
621
|
+
return converter(input, "DotToCamel");
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to PascalCase.
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```ts
|
|
628
|
+
* dotToPascal('hello.world'); // 'HelloWorld'
|
|
629
|
+
* dotToPascal({ 'first.name': 'John' }); // { FirstName: 'John' }
|
|
630
|
+
* ```
|
|
631
|
+
*/
|
|
632
|
+
function dotToPascal(input) {
|
|
633
|
+
return converter(input, "DotToPascal");
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to snake_case.
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```ts
|
|
640
|
+
* dotToSnake('hello.world'); // 'hello_world'
|
|
641
|
+
* dotToSnake({ 'first.name': 'John' }); // { first_name: 'John' }
|
|
642
|
+
* ```
|
|
643
|
+
*/
|
|
644
|
+
function dotToSnake(input) {
|
|
645
|
+
return converter(input, "DotToSnake");
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to dash-case.
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* ```ts
|
|
652
|
+
* dotToDash('hello.world'); // 'hello-world'
|
|
653
|
+
* dotToDash({ 'first.name': 'John' }); // { 'first-name': 'John' }
|
|
654
|
+
* ```
|
|
655
|
+
*/
|
|
656
|
+
function dotToDash(input) {
|
|
657
|
+
return converter(input, "DotToDash");
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to UPPER_SNAKE_CASE.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* ```ts
|
|
664
|
+
* dotToUpperSnake('hello.world'); // 'HELLO_WORLD'
|
|
665
|
+
* dotToUpperSnake({ 'first.name': 'John' }); // { FIRST_NAME: 'John' }
|
|
666
|
+
* ```
|
|
667
|
+
*/
|
|
668
|
+
function dotToUpperSnake(input) {
|
|
669
|
+
return converter(input, "DotToUpperSnake");
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to UPPER-DASH-CASE.
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* ```ts
|
|
676
|
+
* dotToUpperDash('hello.world'); // 'HELLO-WORLD'
|
|
677
|
+
* dotToUpperDash({ 'first.name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
678
|
+
* ```
|
|
679
|
+
*/
|
|
680
|
+
function dotToUpperDash(input) {
|
|
681
|
+
return converter(input, "DotToUpperDash");
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to Train-Case.
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* ```ts
|
|
688
|
+
* dotToTrain('hello.world'); // 'Hello-World'
|
|
689
|
+
* dotToTrain({ 'first.name': 'John' }); // { 'First-Name': 'John' }
|
|
690
|
+
* ```
|
|
691
|
+
*/
|
|
692
|
+
function dotToTrain(input) {
|
|
693
|
+
return converter(input, "DotToTrain");
|
|
694
|
+
}
|
|
375
695
|
//#endregion
|
|
376
696
|
//#region src/upperDashCase/upperDashCase.ts
|
|
377
697
|
/**
|
|
@@ -434,6 +754,30 @@ function upperDashToPascal(input) {
|
|
|
434
754
|
function upperDashToUpperSnake(input) {
|
|
435
755
|
return converter(input, "UpperDashToUpperSnake");
|
|
436
756
|
}
|
|
757
|
+
/**
|
|
758
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to Train-Case.
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* ```ts
|
|
762
|
+
* upperDashToTrain('HELLO-WORLD'); // 'Hello-World'
|
|
763
|
+
* upperDashToTrain({ 'FIRST-NAME': 'John' }); // { 'First-Name': 'John' }
|
|
764
|
+
* ```
|
|
765
|
+
*/
|
|
766
|
+
function upperDashToTrain(input) {
|
|
767
|
+
return converter(input, "UpperDashToTrain");
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to dot.case.
|
|
771
|
+
*
|
|
772
|
+
* @example
|
|
773
|
+
* ```ts
|
|
774
|
+
* upperDashToDot('HELLO-WORLD'); // 'hello.world'
|
|
775
|
+
* upperDashToDot({ 'FIRST-NAME': 'John' }); // { 'first.name': 'John' }
|
|
776
|
+
* ```
|
|
777
|
+
*/
|
|
778
|
+
function upperDashToDot(input) {
|
|
779
|
+
return converter(input, "UpperDashToDot");
|
|
780
|
+
}
|
|
437
781
|
//#endregion
|
|
438
782
|
//#region src/upperSnakeCase/upperSnakeCase.ts
|
|
439
783
|
/**
|
|
@@ -496,5 +840,29 @@ function upperSnakeToPascal(input) {
|
|
|
496
840
|
function upperSnakeToUpperDash(input) {
|
|
497
841
|
return converter(input, "UpperSnakeToUpperDash");
|
|
498
842
|
}
|
|
843
|
+
/**
|
|
844
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to Train-Case.
|
|
845
|
+
*
|
|
846
|
+
* @example
|
|
847
|
+
* ```ts
|
|
848
|
+
* upperSnakeToTrain('HELLO_WORLD'); // 'Hello-World'
|
|
849
|
+
* upperSnakeToTrain({ FIRST_NAME: 'John' }); // { 'First-Name': 'John' }
|
|
850
|
+
* ```
|
|
851
|
+
*/
|
|
852
|
+
function upperSnakeToTrain(input) {
|
|
853
|
+
return converter(input, "UpperSnakeToTrain");
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to dot.case.
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* ```ts
|
|
860
|
+
* upperSnakeToDot('HELLO_WORLD'); // 'hello.world'
|
|
861
|
+
* upperSnakeToDot({ FIRST_NAME: 'John' }); // { 'first.name': 'John' }
|
|
862
|
+
* ```
|
|
863
|
+
*/
|
|
864
|
+
function upperSnakeToDot(input) {
|
|
865
|
+
return converter(input, "UpperSnakeToDot");
|
|
866
|
+
}
|
|
499
867
|
//#endregion
|
|
500
|
-
export { camelToDash, camelToPascal, camelToSnake, camelToUpperDash, camelToUpperSnake, dashToCamel, dashToPascal, dashToSnake, dashToUpperDash, dashToUpperSnake, pascalToCamel, pascalToDash, pascalToSnake, pascalToUpperDash, pascalToUpperSnake, snakeToCamel, snakeToDash, snakeToPascal, snakeToUpperDash, snakeToUpperSnake, upperDashToCamel, upperDashToDash, upperDashToPascal, upperDashToSnake, upperDashToUpperSnake, upperSnakeToCamel, upperSnakeToDash, upperSnakeToPascal, upperSnakeToSnake, upperSnakeToUpperDash };
|
|
868
|
+
export { camelToDash, camelToDot, camelToPascal, camelToSnake, camelToTrain, camelToUpperDash, camelToUpperSnake, dashToCamel, dashToDot, dashToPascal, dashToSnake, dashToTrain, dashToUpperDash, dashToUpperSnake, dotToCamel, dotToDash, dotToPascal, dotToSnake, dotToTrain, dotToUpperDash, dotToUpperSnake, pascalToCamel, pascalToDash, pascalToDot, pascalToSnake, pascalToTrain, pascalToUpperDash, pascalToUpperSnake, snakeToCamel, snakeToDash, snakeToDot, snakeToPascal, snakeToTrain, snakeToUpperDash, snakeToUpperSnake, trainToCamel, trainToDash, trainToDot, trainToPascal, trainToSnake, trainToUpperDash, trainToUpperSnake, upperDashToCamel, upperDashToDash, upperDashToDot, upperDashToPascal, upperDashToSnake, upperDashToTrain, upperDashToUpperSnake, upperSnakeToCamel, upperSnakeToDash, upperSnakeToDot, upperSnakeToPascal, upperSnakeToSnake, upperSnakeToTrain, upperSnakeToUpperDash };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caseparser",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Convert Strings/Arrays/Objects from a type of case to another one.",
|
|
5
5
|
"author": "Fernando Machado Bernardino <fernandombernardino@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/NandoMB/caseparser#readme",
|
|
@@ -39,19 +39,23 @@
|
|
|
39
39
|
"dist"
|
|
40
40
|
],
|
|
41
41
|
"scripts": {
|
|
42
|
-
"dev": "vitest",
|
|
43
|
-
"test": "vitest run",
|
|
44
|
-
"coverage": "vitest run --coverage",
|
|
42
|
+
"dev": "vitest --project node",
|
|
43
|
+
"test": "vitest run --project node",
|
|
44
|
+
"coverage": "vitest run --project node --coverage",
|
|
45
45
|
"build": "tsdown",
|
|
46
46
|
"lint": "tsc",
|
|
47
47
|
"ci": "pnpm run lint && pnpm run test && pnpm run build",
|
|
48
48
|
"release": "node scripts/release.js",
|
|
49
|
-
"changeset:version": "changeset version && node scripts/sync-jsr-version.js"
|
|
49
|
+
"changeset:version": "changeset version && node scripts/sync-jsr-version.js",
|
|
50
|
+
"test:browser": "vitest run --project browser",
|
|
51
|
+
"test:examples": "node scripts/test-examples.js"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
54
|
"@changesets/cli": "^3.0.3",
|
|
53
|
-
"@types/node": "^
|
|
55
|
+
"@types/node": "^26.6.2",
|
|
56
|
+
"@vitest/browser-playwright": "^5.0.1",
|
|
54
57
|
"@vitest/coverage-istanbul": "^5.0.1",
|
|
58
|
+
"playwright": "^1.63.0",
|
|
55
59
|
"tsdown": "^0.23.0",
|
|
56
60
|
"typescript": "^7.0.2",
|
|
57
61
|
"vitest": "^5.0.1"
|
|
@@ -67,11 +71,15 @@
|
|
|
67
71
|
"pascal case",
|
|
68
72
|
"upper snake case",
|
|
69
73
|
"upper dash case",
|
|
74
|
+
"train case",
|
|
75
|
+
"dot case",
|
|
70
76
|
"camelCase",
|
|
71
77
|
"snake_case",
|
|
72
78
|
"dash-case",
|
|
73
79
|
"PascalCase",
|
|
74
80
|
"UPPER_SNAKE_CASE",
|
|
75
|
-
"UPPER-DASH-CASE"
|
|
81
|
+
"UPPER-DASH-CASE",
|
|
82
|
+
"Train-Case",
|
|
83
|
+
"dot.case"
|
|
76
84
|
]
|
|
77
85
|
}
|