caseparser 4.1.0 → 4.2.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 +17 -12
- package/dist/index.cjs +515 -1
- package/dist/index.d.cts +392 -10
- package/dist/index.d.ts +392 -10
- package/dist/index.js +482 -2
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -78,6 +78,40 @@ const DotToSnake = (str) => DashToSnake(DotToDash(str));
|
|
|
78
78
|
const DotToTrain = (str) => DashToTrain(DotToDash(str));
|
|
79
79
|
const DotToUpperDash = (str) => Uppercase(DotToDash(str));
|
|
80
80
|
const DotToUpperSnake = (str) => DashToUpperSnake(DotToDash(str));
|
|
81
|
+
const DashToTitle = (str) => str.split("-").map(Capitalize).join(" ");
|
|
82
|
+
const DashToSentence = (str) => Capitalize(str.replace(/(\-)/g, " "));
|
|
83
|
+
const CamelToTitle = (str) => DashToTitle(CamelToDash(str));
|
|
84
|
+
const CamelToSentence = (str) => DashToSentence(CamelToDash(str));
|
|
85
|
+
const PascalToTitle = (str) => DashToTitle(PascalToDash(str));
|
|
86
|
+
const PascalToSentence = (str) => DashToSentence(PascalToDash(str));
|
|
87
|
+
const SnakeToTitle = (str) => DashToTitle(SnakeToDash(str));
|
|
88
|
+
const SnakeToSentence = (str) => DashToSentence(SnakeToDash(str));
|
|
89
|
+
const UpperSnakeToTitle = (str) => DashToTitle(UpperSnakeToDash(str));
|
|
90
|
+
const UpperSnakeToSentence = (str) => DashToSentence(UpperSnakeToDash(str));
|
|
91
|
+
const UpperDashToTitle = (str) => DashToTitle(UpperDashToDash(str));
|
|
92
|
+
const UpperDashToSentence = (str) => DashToSentence(UpperDashToDash(str));
|
|
93
|
+
const TrainToTitle = (str) => DashToTitle(TrainToDash(str));
|
|
94
|
+
const TrainToSentence = (str) => DashToSentence(TrainToDash(str));
|
|
95
|
+
const DotToTitle = (str) => DashToTitle(DotToDash(str));
|
|
96
|
+
const DotToSentence = (str) => DashToSentence(DotToDash(str));
|
|
97
|
+
const TitleToDash = (str) => Lowercase(str).replace(/( )/g, "-");
|
|
98
|
+
const TitleToCamel = (str) => DashToCamel(TitleToDash(str));
|
|
99
|
+
const TitleToPascal = (str) => DashToPascal(TitleToDash(str));
|
|
100
|
+
const TitleToSnake = (str) => DashToSnake(TitleToDash(str));
|
|
101
|
+
const TitleToUpperSnake = (str) => DashToUpperSnake(TitleToDash(str));
|
|
102
|
+
const TitleToUpperDash = (str) => DashToUpperDash(TitleToDash(str));
|
|
103
|
+
const TitleToTrain = (str) => DashToTrain(TitleToDash(str));
|
|
104
|
+
const TitleToDot = (str) => DashToDot(TitleToDash(str));
|
|
105
|
+
const TitleToSentence = (str) => DashToSentence(TitleToDash(str));
|
|
106
|
+
const SentenceToDash = (str) => Lowercase(str).replace(/( )/g, "-");
|
|
107
|
+
const SentenceToCamel = (str) => DashToCamel(SentenceToDash(str));
|
|
108
|
+
const SentenceToPascal = (str) => DashToPascal(SentenceToDash(str));
|
|
109
|
+
const SentenceToSnake = (str) => DashToSnake(SentenceToDash(str));
|
|
110
|
+
const SentenceToUpperSnake = (str) => DashToUpperSnake(SentenceToDash(str));
|
|
111
|
+
const SentenceToUpperDash = (str) => DashToUpperDash(SentenceToDash(str));
|
|
112
|
+
const SentenceToTrain = (str) => DashToTrain(SentenceToDash(str));
|
|
113
|
+
const SentenceToDot = (str) => DashToDot(SentenceToDash(str));
|
|
114
|
+
const SentenceToTitle = (str) => DashToTitle(SentenceToDash(str));
|
|
81
115
|
function parse(input, type) {
|
|
82
116
|
return {
|
|
83
117
|
CamelToDash,
|
|
@@ -135,7 +169,41 @@ function parse(input, type) {
|
|
|
135
169
|
DotToDash,
|
|
136
170
|
DotToUpperSnake,
|
|
137
171
|
DotToUpperDash,
|
|
138
|
-
DotToTrain
|
|
172
|
+
DotToTrain,
|
|
173
|
+
CamelToTitle,
|
|
174
|
+
CamelToSentence,
|
|
175
|
+
PascalToTitle,
|
|
176
|
+
PascalToSentence,
|
|
177
|
+
SnakeToTitle,
|
|
178
|
+
SnakeToSentence,
|
|
179
|
+
DashToTitle,
|
|
180
|
+
DashToSentence,
|
|
181
|
+
UpperSnakeToTitle,
|
|
182
|
+
UpperSnakeToSentence,
|
|
183
|
+
UpperDashToTitle,
|
|
184
|
+
UpperDashToSentence,
|
|
185
|
+
TrainToTitle,
|
|
186
|
+
TrainToSentence,
|
|
187
|
+
DotToTitle,
|
|
188
|
+
DotToSentence,
|
|
189
|
+
TitleToCamel,
|
|
190
|
+
TitleToPascal,
|
|
191
|
+
TitleToSnake,
|
|
192
|
+
TitleToDash,
|
|
193
|
+
TitleToUpperSnake,
|
|
194
|
+
TitleToUpperDash,
|
|
195
|
+
TitleToTrain,
|
|
196
|
+
TitleToDot,
|
|
197
|
+
TitleToSentence,
|
|
198
|
+
SentenceToCamel,
|
|
199
|
+
SentenceToPascal,
|
|
200
|
+
SentenceToSnake,
|
|
201
|
+
SentenceToDash,
|
|
202
|
+
SentenceToUpperSnake,
|
|
203
|
+
SentenceToUpperDash,
|
|
204
|
+
SentenceToTrain,
|
|
205
|
+
SentenceToDot,
|
|
206
|
+
SentenceToTitle
|
|
139
207
|
}[type](input);
|
|
140
208
|
}
|
|
141
209
|
//#endregion
|
|
@@ -262,6 +330,30 @@ function camelToTrain(input) {
|
|
|
262
330
|
function camelToDot(input) {
|
|
263
331
|
return converter(input, "CamelToDot");
|
|
264
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to Title Case.
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* camelToTitle('helloWorld'); // 'Hello World'
|
|
339
|
+
* camelToTitle({ firstName: 'John' }); // { 'First Name': 'John' }
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
function camelToTitle(input) {
|
|
343
|
+
return converter(input, "CamelToTitle");
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to Sentence case.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```ts
|
|
350
|
+
* camelToSentence('helloWorld'); // 'Hello world'
|
|
351
|
+
* camelToSentence({ firstName: 'John' }); // { 'First name': 'John' }
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
function camelToSentence(input) {
|
|
355
|
+
return converter(input, "CamelToSentence");
|
|
356
|
+
}
|
|
265
357
|
//#endregion
|
|
266
358
|
//#region src/dashCase/dashCase.ts
|
|
267
359
|
/**
|
|
@@ -348,6 +440,30 @@ function dashToTrain(input) {
|
|
|
348
440
|
function dashToDot(input) {
|
|
349
441
|
return converter(input, "DashToDot");
|
|
350
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to Title Case.
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```ts
|
|
448
|
+
* dashToTitle('hello-world'); // 'Hello World'
|
|
449
|
+
* dashToTitle({ 'first-name': 'John' }); // { 'First Name': 'John' }
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
function dashToTitle(input) {
|
|
453
|
+
return converter(input, "DashToTitle");
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to Sentence case.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts
|
|
460
|
+
* dashToSentence('hello-world'); // 'Hello world'
|
|
461
|
+
* dashToSentence({ 'first-name': 'John' }); // { 'First name': 'John' }
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
function dashToSentence(input) {
|
|
465
|
+
return converter(input, "DashToSentence");
|
|
466
|
+
}
|
|
351
467
|
//#endregion
|
|
352
468
|
//#region src/pascalCase/pascalCase.ts
|
|
353
469
|
/**
|
|
@@ -434,6 +550,30 @@ function pascalToTrain(input) {
|
|
|
434
550
|
function pascalToDot(input) {
|
|
435
551
|
return converter(input, "PascalToDot");
|
|
436
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to Title Case.
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```ts
|
|
558
|
+
* pascalToTitle('HelloWorld'); // 'Hello World'
|
|
559
|
+
* pascalToTitle({ FirstName: 'John' }); // { 'First Name': 'John' }
|
|
560
|
+
* ```
|
|
561
|
+
*/
|
|
562
|
+
function pascalToTitle(input) {
|
|
563
|
+
return converter(input, "PascalToTitle");
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to Sentence case.
|
|
567
|
+
*
|
|
568
|
+
* @example
|
|
569
|
+
* ```ts
|
|
570
|
+
* pascalToSentence('HelloWorld'); // 'Hello world'
|
|
571
|
+
* pascalToSentence({ FirstName: 'John' }); // { 'First name': 'John' }
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
574
|
+
function pascalToSentence(input) {
|
|
575
|
+
return converter(input, "PascalToSentence");
|
|
576
|
+
}
|
|
437
577
|
//#endregion
|
|
438
578
|
//#region src/snakeCase/snakeCase.ts
|
|
439
579
|
/**
|
|
@@ -520,6 +660,30 @@ function snakeToTrain(input) {
|
|
|
520
660
|
function snakeToDot(input) {
|
|
521
661
|
return converter(input, "SnakeToDot");
|
|
522
662
|
}
|
|
663
|
+
/**
|
|
664
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to Title Case.
|
|
665
|
+
*
|
|
666
|
+
* @example
|
|
667
|
+
* ```ts
|
|
668
|
+
* snakeToTitle('hello_world'); // 'Hello World'
|
|
669
|
+
* snakeToTitle({ first_name: 'John' }); // { 'First Name': 'John' }
|
|
670
|
+
* ```
|
|
671
|
+
*/
|
|
672
|
+
function snakeToTitle(input) {
|
|
673
|
+
return converter(input, "SnakeToTitle");
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to Sentence case.
|
|
677
|
+
*
|
|
678
|
+
* @example
|
|
679
|
+
* ```ts
|
|
680
|
+
* snakeToSentence('hello_world'); // 'Hello world'
|
|
681
|
+
* snakeToSentence({ first_name: 'John' }); // { 'First name': 'John' }
|
|
682
|
+
* ```
|
|
683
|
+
*/
|
|
684
|
+
function snakeToSentence(input) {
|
|
685
|
+
return converter(input, "SnakeToSentence");
|
|
686
|
+
}
|
|
523
687
|
//#endregion
|
|
524
688
|
//#region src/trainCase/trainCase.ts
|
|
525
689
|
/**
|
|
@@ -606,6 +770,30 @@ function trainToUpperDash(input) {
|
|
|
606
770
|
function trainToDot(input) {
|
|
607
771
|
return converter(input, "TrainToDot");
|
|
608
772
|
}
|
|
773
|
+
/**
|
|
774
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to Title Case.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* ```ts
|
|
778
|
+
* trainToTitle('Hello-World'); // 'Hello World'
|
|
779
|
+
* trainToTitle({ 'First-Name': 'John' }); // { 'First Name': 'John' }
|
|
780
|
+
* ```
|
|
781
|
+
*/
|
|
782
|
+
function trainToTitle(input) {
|
|
783
|
+
return converter(input, "TrainToTitle");
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to Sentence case.
|
|
787
|
+
*
|
|
788
|
+
* @example
|
|
789
|
+
* ```ts
|
|
790
|
+
* trainToSentence('Hello-World'); // 'Hello world'
|
|
791
|
+
* trainToSentence({ 'First-Name': 'John' }); // { 'First name': 'John' }
|
|
792
|
+
* ```
|
|
793
|
+
*/
|
|
794
|
+
function trainToSentence(input) {
|
|
795
|
+
return converter(input, "TrainToSentence");
|
|
796
|
+
}
|
|
609
797
|
//#endregion
|
|
610
798
|
//#region src/dotCase/dotCase.ts
|
|
611
799
|
/**
|
|
@@ -692,6 +880,250 @@ function dotToUpperDash(input) {
|
|
|
692
880
|
function dotToTrain(input) {
|
|
693
881
|
return converter(input, "DotToTrain");
|
|
694
882
|
}
|
|
883
|
+
/**
|
|
884
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to Title Case.
|
|
885
|
+
*
|
|
886
|
+
* @example
|
|
887
|
+
* ```ts
|
|
888
|
+
* dotToTitle('hello.world'); // 'Hello World'
|
|
889
|
+
* dotToTitle({ 'first.name': 'John' }); // { 'First Name': 'John' }
|
|
890
|
+
* ```
|
|
891
|
+
*/
|
|
892
|
+
function dotToTitle(input) {
|
|
893
|
+
return converter(input, "DotToTitle");
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to Sentence case.
|
|
897
|
+
*
|
|
898
|
+
* @example
|
|
899
|
+
* ```ts
|
|
900
|
+
* dotToSentence('hello.world'); // 'Hello world'
|
|
901
|
+
* dotToSentence({ 'first.name': 'John' }); // { 'First name': 'John' }
|
|
902
|
+
* ```
|
|
903
|
+
*/
|
|
904
|
+
function dotToSentence(input) {
|
|
905
|
+
return converter(input, "DotToSentence");
|
|
906
|
+
}
|
|
907
|
+
//#endregion
|
|
908
|
+
//#region src/titleCase/titleCase.ts
|
|
909
|
+
/**
|
|
910
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to camelCase.
|
|
911
|
+
*
|
|
912
|
+
* @example
|
|
913
|
+
* ```ts
|
|
914
|
+
* titleToCamel('Hello World'); // 'helloWorld'
|
|
915
|
+
* titleToCamel({ 'First Name': 'John' }); // { firstName: 'John' }
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
918
|
+
function titleToCamel(input) {
|
|
919
|
+
return converter(input, "TitleToCamel");
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to PascalCase.
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* ```ts
|
|
926
|
+
* titleToPascal('Hello World'); // 'HelloWorld'
|
|
927
|
+
* titleToPascal({ 'First Name': 'John' }); // { FirstName: 'John' }
|
|
928
|
+
* ```
|
|
929
|
+
*/
|
|
930
|
+
function titleToPascal(input) {
|
|
931
|
+
return converter(input, "TitleToPascal");
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to snake_case.
|
|
935
|
+
*
|
|
936
|
+
* @example
|
|
937
|
+
* ```ts
|
|
938
|
+
* titleToSnake('Hello World'); // 'hello_world'
|
|
939
|
+
* titleToSnake({ 'First Name': 'John' }); // { first_name: 'John' }
|
|
940
|
+
* ```
|
|
941
|
+
*/
|
|
942
|
+
function titleToSnake(input) {
|
|
943
|
+
return converter(input, "TitleToSnake");
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to dash-case.
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```ts
|
|
950
|
+
* titleToDash('Hello World'); // 'hello-world'
|
|
951
|
+
* titleToDash({ 'First Name': 'John' }); // { 'first-name': 'John' }
|
|
952
|
+
* ```
|
|
953
|
+
*/
|
|
954
|
+
function titleToDash(input) {
|
|
955
|
+
return converter(input, "TitleToDash");
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to UPPER_SNAKE_CASE.
|
|
959
|
+
*
|
|
960
|
+
* @example
|
|
961
|
+
* ```ts
|
|
962
|
+
* titleToUpperSnake('Hello World'); // 'HELLO_WORLD'
|
|
963
|
+
* titleToUpperSnake({ 'First Name': 'John' }); // { FIRST_NAME: 'John' }
|
|
964
|
+
* ```
|
|
965
|
+
*/
|
|
966
|
+
function titleToUpperSnake(input) {
|
|
967
|
+
return converter(input, "TitleToUpperSnake");
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to UPPER-DASH-CASE.
|
|
971
|
+
*
|
|
972
|
+
* @example
|
|
973
|
+
* ```ts
|
|
974
|
+
* titleToUpperDash('Hello World'); // 'HELLO-WORLD'
|
|
975
|
+
* titleToUpperDash({ 'First Name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
976
|
+
* ```
|
|
977
|
+
*/
|
|
978
|
+
function titleToUpperDash(input) {
|
|
979
|
+
return converter(input, "TitleToUpperDash");
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to Train-Case.
|
|
983
|
+
*
|
|
984
|
+
* @example
|
|
985
|
+
* ```ts
|
|
986
|
+
* titleToTrain('Hello World'); // 'Hello-World'
|
|
987
|
+
* titleToTrain({ 'First Name': 'John' }); // { 'First-Name': 'John' }
|
|
988
|
+
* ```
|
|
989
|
+
*/
|
|
990
|
+
function titleToTrain(input) {
|
|
991
|
+
return converter(input, "TitleToTrain");
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to dot.case.
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* ```ts
|
|
998
|
+
* titleToDot('Hello World'); // 'hello.world'
|
|
999
|
+
* titleToDot({ 'First Name': 'John' }); // { 'first.name': 'John' }
|
|
1000
|
+
* ```
|
|
1001
|
+
*/
|
|
1002
|
+
function titleToDot(input) {
|
|
1003
|
+
return converter(input, "TitleToDot");
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to Sentence case.
|
|
1007
|
+
*
|
|
1008
|
+
* @example
|
|
1009
|
+
* ```ts
|
|
1010
|
+
* titleToSentence('Hello World'); // 'Hello world'
|
|
1011
|
+
* titleToSentence({ 'First Name': 'John' }); // { 'First name': 'John' }
|
|
1012
|
+
* ```
|
|
1013
|
+
*/
|
|
1014
|
+
function titleToSentence(input) {
|
|
1015
|
+
return converter(input, "TitleToSentence");
|
|
1016
|
+
}
|
|
1017
|
+
//#endregion
|
|
1018
|
+
//#region src/sentenceCase/sentenceCase.ts
|
|
1019
|
+
/**
|
|
1020
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to camelCase.
|
|
1021
|
+
*
|
|
1022
|
+
* @example
|
|
1023
|
+
* ```ts
|
|
1024
|
+
* sentenceToCamel('Hello world'); // 'helloWorld'
|
|
1025
|
+
* sentenceToCamel({ 'First name': 'John' }); // { firstName: 'John' }
|
|
1026
|
+
* ```
|
|
1027
|
+
*/
|
|
1028
|
+
function sentenceToCamel(input) {
|
|
1029
|
+
return converter(input, "SentenceToCamel");
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to PascalCase.
|
|
1033
|
+
*
|
|
1034
|
+
* @example
|
|
1035
|
+
* ```ts
|
|
1036
|
+
* sentenceToPascal('Hello world'); // 'HelloWorld'
|
|
1037
|
+
* sentenceToPascal({ 'First name': 'John' }); // { FirstName: 'John' }
|
|
1038
|
+
* ```
|
|
1039
|
+
*/
|
|
1040
|
+
function sentenceToPascal(input) {
|
|
1041
|
+
return converter(input, "SentenceToPascal");
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to snake_case.
|
|
1045
|
+
*
|
|
1046
|
+
* @example
|
|
1047
|
+
* ```ts
|
|
1048
|
+
* sentenceToSnake('Hello world'); // 'hello_world'
|
|
1049
|
+
* sentenceToSnake({ 'First name': 'John' }); // { first_name: 'John' }
|
|
1050
|
+
* ```
|
|
1051
|
+
*/
|
|
1052
|
+
function sentenceToSnake(input) {
|
|
1053
|
+
return converter(input, "SentenceToSnake");
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to dash-case.
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```ts
|
|
1060
|
+
* sentenceToDash('Hello world'); // 'hello-world'
|
|
1061
|
+
* sentenceToDash({ 'First name': 'John' }); // { 'first-name': 'John' }
|
|
1062
|
+
* ```
|
|
1063
|
+
*/
|
|
1064
|
+
function sentenceToDash(input) {
|
|
1065
|
+
return converter(input, "SentenceToDash");
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to UPPER_SNAKE_CASE.
|
|
1069
|
+
*
|
|
1070
|
+
* @example
|
|
1071
|
+
* ```ts
|
|
1072
|
+
* sentenceToUpperSnake('Hello world'); // 'HELLO_WORLD'
|
|
1073
|
+
* sentenceToUpperSnake({ 'First name': 'John' }); // { FIRST_NAME: 'John' }
|
|
1074
|
+
* ```
|
|
1075
|
+
*/
|
|
1076
|
+
function sentenceToUpperSnake(input) {
|
|
1077
|
+
return converter(input, "SentenceToUpperSnake");
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to UPPER-DASH-CASE.
|
|
1081
|
+
*
|
|
1082
|
+
* @example
|
|
1083
|
+
* ```ts
|
|
1084
|
+
* sentenceToUpperDash('Hello world'); // 'HELLO-WORLD'
|
|
1085
|
+
* sentenceToUpperDash({ 'First name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
1086
|
+
* ```
|
|
1087
|
+
*/
|
|
1088
|
+
function sentenceToUpperDash(input) {
|
|
1089
|
+
return converter(input, "SentenceToUpperDash");
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to Train-Case.
|
|
1093
|
+
*
|
|
1094
|
+
* @example
|
|
1095
|
+
* ```ts
|
|
1096
|
+
* sentenceToTrain('Hello world'); // 'Hello-World'
|
|
1097
|
+
* sentenceToTrain({ 'First name': 'John' }); // { 'First-Name': 'John' }
|
|
1098
|
+
* ```
|
|
1099
|
+
*/
|
|
1100
|
+
function sentenceToTrain(input) {
|
|
1101
|
+
return converter(input, "SentenceToTrain");
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to dot.case.
|
|
1105
|
+
*
|
|
1106
|
+
* @example
|
|
1107
|
+
* ```ts
|
|
1108
|
+
* sentenceToDot('Hello world'); // 'hello.world'
|
|
1109
|
+
* sentenceToDot({ 'First name': 'John' }); // { 'first.name': 'John' }
|
|
1110
|
+
* ```
|
|
1111
|
+
*/
|
|
1112
|
+
function sentenceToDot(input) {
|
|
1113
|
+
return converter(input, "SentenceToDot");
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to Title Case.
|
|
1117
|
+
*
|
|
1118
|
+
* @example
|
|
1119
|
+
* ```ts
|
|
1120
|
+
* sentenceToTitle('Hello world'); // 'Hello World'
|
|
1121
|
+
* sentenceToTitle({ 'First name': 'John' }); // { 'First Name': 'John' }
|
|
1122
|
+
* ```
|
|
1123
|
+
*/
|
|
1124
|
+
function sentenceToTitle(input) {
|
|
1125
|
+
return converter(input, "SentenceToTitle");
|
|
1126
|
+
}
|
|
695
1127
|
//#endregion
|
|
696
1128
|
//#region src/upperDashCase/upperDashCase.ts
|
|
697
1129
|
/**
|
|
@@ -778,6 +1210,30 @@ function upperDashToTrain(input) {
|
|
|
778
1210
|
function upperDashToDot(input) {
|
|
779
1211
|
return converter(input, "UpperDashToDot");
|
|
780
1212
|
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to Title Case.
|
|
1215
|
+
*
|
|
1216
|
+
* @example
|
|
1217
|
+
* ```ts
|
|
1218
|
+
* upperDashToTitle('HELLO-WORLD'); // 'Hello World'
|
|
1219
|
+
* upperDashToTitle({ 'FIRST-NAME': 'John' }); // { 'First Name': 'John' }
|
|
1220
|
+
* ```
|
|
1221
|
+
*/
|
|
1222
|
+
function upperDashToTitle(input) {
|
|
1223
|
+
return converter(input, "UpperDashToTitle");
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to Sentence case.
|
|
1227
|
+
*
|
|
1228
|
+
* @example
|
|
1229
|
+
* ```ts
|
|
1230
|
+
* upperDashToSentence('HELLO-WORLD'); // 'Hello world'
|
|
1231
|
+
* upperDashToSentence({ 'FIRST-NAME': 'John' }); // { 'First name': 'John' }
|
|
1232
|
+
* ```
|
|
1233
|
+
*/
|
|
1234
|
+
function upperDashToSentence(input) {
|
|
1235
|
+
return converter(input, "UpperDashToSentence");
|
|
1236
|
+
}
|
|
781
1237
|
//#endregion
|
|
782
1238
|
//#region src/upperSnakeCase/upperSnakeCase.ts
|
|
783
1239
|
/**
|
|
@@ -864,5 +1320,29 @@ function upperSnakeToTrain(input) {
|
|
|
864
1320
|
function upperSnakeToDot(input) {
|
|
865
1321
|
return converter(input, "UpperSnakeToDot");
|
|
866
1322
|
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to Title Case.
|
|
1325
|
+
*
|
|
1326
|
+
* @example
|
|
1327
|
+
* ```ts
|
|
1328
|
+
* upperSnakeToTitle('HELLO_WORLD'); // 'Hello World'
|
|
1329
|
+
* upperSnakeToTitle({ FIRST_NAME: 'John' }); // { 'First Name': 'John' }
|
|
1330
|
+
* ```
|
|
1331
|
+
*/
|
|
1332
|
+
function upperSnakeToTitle(input) {
|
|
1333
|
+
return converter(input, "UpperSnakeToTitle");
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to Sentence case.
|
|
1337
|
+
*
|
|
1338
|
+
* @example
|
|
1339
|
+
* ```ts
|
|
1340
|
+
* upperSnakeToSentence('HELLO_WORLD'); // 'Hello world'
|
|
1341
|
+
* upperSnakeToSentence({ FIRST_NAME: 'John' }); // { 'First name': 'John' }
|
|
1342
|
+
* ```
|
|
1343
|
+
*/
|
|
1344
|
+
function upperSnakeToSentence(input) {
|
|
1345
|
+
return converter(input, "UpperSnakeToSentence");
|
|
1346
|
+
}
|
|
867
1347
|
//#endregion
|
|
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 };
|
|
1348
|
+
export { camelToDash, camelToDot, camelToPascal, camelToSentence, camelToSnake, camelToTitle, camelToTrain, camelToUpperDash, camelToUpperSnake, dashToCamel, dashToDot, dashToPascal, dashToSentence, dashToSnake, dashToTitle, dashToTrain, dashToUpperDash, dashToUpperSnake, dotToCamel, dotToDash, dotToPascal, dotToSentence, dotToSnake, dotToTitle, dotToTrain, dotToUpperDash, dotToUpperSnake, pascalToCamel, pascalToDash, pascalToDot, pascalToSentence, pascalToSnake, pascalToTitle, pascalToTrain, pascalToUpperDash, pascalToUpperSnake, sentenceToCamel, sentenceToDash, sentenceToDot, sentenceToPascal, sentenceToSnake, sentenceToTitle, sentenceToTrain, sentenceToUpperDash, sentenceToUpperSnake, snakeToCamel, snakeToDash, snakeToDot, snakeToPascal, snakeToSentence, snakeToTitle, snakeToTrain, snakeToUpperDash, snakeToUpperSnake, titleToCamel, titleToDash, titleToDot, titleToPascal, titleToSentence, titleToSnake, titleToTrain, titleToUpperDash, titleToUpperSnake, trainToCamel, trainToDash, trainToDot, trainToPascal, trainToSentence, trainToSnake, trainToTitle, trainToUpperDash, trainToUpperSnake, upperDashToCamel, upperDashToDash, upperDashToDot, upperDashToPascal, upperDashToSentence, upperDashToSnake, upperDashToTitle, upperDashToTrain, upperDashToUpperSnake, upperSnakeToCamel, upperSnakeToDash, upperSnakeToDot, upperSnakeToPascal, upperSnakeToSentence, upperSnakeToSnake, upperSnakeToTitle, upperSnakeToTrain, upperSnakeToUpperDash };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caseparser",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.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",
|
|
@@ -73,6 +73,8 @@
|
|
|
73
73
|
"upper dash case",
|
|
74
74
|
"train case",
|
|
75
75
|
"dot case",
|
|
76
|
+
"title case",
|
|
77
|
+
"sentence case",
|
|
76
78
|
"camelCase",
|
|
77
79
|
"snake_case",
|
|
78
80
|
"dash-case",
|
|
@@ -80,6 +82,8 @@
|
|
|
80
82
|
"UPPER_SNAKE_CASE",
|
|
81
83
|
"UPPER-DASH-CASE",
|
|
82
84
|
"Train-Case",
|
|
83
|
-
"dot.case"
|
|
85
|
+
"dot.case",
|
|
86
|
+
"Title Case",
|
|
87
|
+
"Sentence case"
|
|
84
88
|
]
|
|
85
89
|
}
|