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/README.md
CHANGED
|
@@ -105,24 +105,29 @@ Every function is named `<from>To<To>`, e.g. `snakeToCamel`. The case names are:
|
|
|
105
105
|
| `upperDash` | `HELLO-WORLD` |
|
|
106
106
|
| `train` | `Hello-World` |
|
|
107
107
|
| `dot` | `hello.world` |
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
- **
|
|
114
|
-
- **
|
|
115
|
-
- **
|
|
116
|
-
- **
|
|
117
|
-
- **
|
|
118
|
-
- **
|
|
108
|
+
| `title` | `Hello World` |
|
|
109
|
+
| `sentence` | `Hello world` |
|
|
110
|
+
|
|
111
|
+
All 90 functions:
|
|
112
|
+
|
|
113
|
+
- **camelCase:** `camelToPascal`, `camelToSnake`, `camelToDash`, `camelToUpperSnake`, `camelToUpperDash`, `camelToTrain`, `camelToDot`, `camelToTitle`, `camelToSentence`
|
|
114
|
+
- **PascalCase:** `pascalToCamel`, `pascalToSnake`, `pascalToDash`, `pascalToUpperSnake`, `pascalToUpperDash`, `pascalToTrain`, `pascalToDot`, `pascalToTitle`, `pascalToSentence`
|
|
115
|
+
- **snake_case:** `snakeToCamel`, `snakeToPascal`, `snakeToDash`, `snakeToUpperSnake`, `snakeToUpperDash`, `snakeToTrain`, `snakeToDot`, `snakeToTitle`, `snakeToSentence`
|
|
116
|
+
- **dash-case:** `dashToCamel`, `dashToPascal`, `dashToSnake`, `dashToUpperSnake`, `dashToUpperDash`, `dashToTrain`, `dashToDot`, `dashToTitle`, `dashToSentence`
|
|
117
|
+
- **UPPER_SNAKE_CASE:** `upperSnakeToCamel`, `upperSnakeToPascal`, `upperSnakeToSnake`, `upperSnakeToDash`, `upperSnakeToUpperDash`, `upperSnakeToTrain`, `upperSnakeToDot`, `upperSnakeToTitle`, `upperSnakeToSentence`
|
|
118
|
+
- **UPPER-DASH-CASE:** `upperDashToCamel`, `upperDashToPascal`, `upperDashToSnake`, `upperDashToDash`, `upperDashToUpperSnake`, `upperDashToTrain`, `upperDashToDot`, `upperDashToTitle`, `upperDashToSentence`
|
|
119
|
+
- **Train-Case:** `trainToCamel`, `trainToPascal`, `trainToSnake`, `trainToDash`, `trainToUpperSnake`, `trainToUpperDash`, `trainToDot`, `trainToTitle`, `trainToSentence`
|
|
120
|
+
- **dot.case:** `dotToCamel`, `dotToPascal`, `dotToSnake`, `dotToDash`, `dotToUpperSnake`, `dotToUpperDash`, `dotToTrain`, `dotToTitle`, `dotToSentence`
|
|
121
|
+
- **Title Case:** `titleToCamel`, `titleToPascal`, `titleToSnake`, `titleToDash`, `titleToUpperSnake`, `titleToUpperDash`, `titleToTrain`, `titleToDot`, `titleToSentence`
|
|
122
|
+
- **Sentence case:** `sentenceToCamel`, `sentenceToPascal`, `sentenceToSnake`, `sentenceToDash`, `sentenceToUpperSnake`, `sentenceToUpperDash`, `sentenceToTrain`, `sentenceToDot`, `sentenceToTitle`
|
|
119
123
|
|
|
120
124
|
## Behavior and limitations
|
|
121
125
|
|
|
122
126
|
- **Only keys are converted, never values.** In `{ userName: 'johnDoe' }`, `userName` becomes `user_name` but `'johnDoe'` is kept. Strings inside arrays are kept too.
|
|
123
127
|
- **Only plain objects are traversed.** `Date`, `Map`, `Set` and class instances are returned as they are (same reference), without converting their contents.
|
|
124
128
|
- **Acronyms are split letter by letter**, because every uppercase letter starts a new word: `camelToSnake('userID')` → `'user_i_d'`. Prefer `userId` style keys.
|
|
125
|
-
- **Train-Case words are lowercased** before converting, so `trainToCamel('X-API-Key')` → `'xApiKey'`.
|
|
129
|
+
- **Train-Case, Title Case and Sentence case words are lowercased** before converting, so `trainToCamel('X-API-Key')` → `'xApiKey'` and `titleToCamel('First Name')` → `'firstName'`.
|
|
130
|
+
- **Title Case capitalizes every word**, including short ones: `camelToTitle('termsOfUse')` → `'Terms Of Use'`.
|
|
126
131
|
- **Numbers are not word boundaries:** `camelToSnake('html5Parser')` → `'html5_parser'`, `snakeToCamel('user_1_name')` → `'user1Name'`.
|
|
127
132
|
|
|
128
133
|
## Security
|
package/dist/index.cjs
CHANGED
|
@@ -79,6 +79,40 @@ const DotToSnake = (str) => DashToSnake(DotToDash(str));
|
|
|
79
79
|
const DotToTrain = (str) => DashToTrain(DotToDash(str));
|
|
80
80
|
const DotToUpperDash = (str) => Uppercase(DotToDash(str));
|
|
81
81
|
const DotToUpperSnake = (str) => DashToUpperSnake(DotToDash(str));
|
|
82
|
+
const DashToTitle = (str) => str.split("-").map(Capitalize).join(" ");
|
|
83
|
+
const DashToSentence = (str) => Capitalize(str.replace(/(\-)/g, " "));
|
|
84
|
+
const CamelToTitle = (str) => DashToTitle(CamelToDash(str));
|
|
85
|
+
const CamelToSentence = (str) => DashToSentence(CamelToDash(str));
|
|
86
|
+
const PascalToTitle = (str) => DashToTitle(PascalToDash(str));
|
|
87
|
+
const PascalToSentence = (str) => DashToSentence(PascalToDash(str));
|
|
88
|
+
const SnakeToTitle = (str) => DashToTitle(SnakeToDash(str));
|
|
89
|
+
const SnakeToSentence = (str) => DashToSentence(SnakeToDash(str));
|
|
90
|
+
const UpperSnakeToTitle = (str) => DashToTitle(UpperSnakeToDash(str));
|
|
91
|
+
const UpperSnakeToSentence = (str) => DashToSentence(UpperSnakeToDash(str));
|
|
92
|
+
const UpperDashToTitle = (str) => DashToTitle(UpperDashToDash(str));
|
|
93
|
+
const UpperDashToSentence = (str) => DashToSentence(UpperDashToDash(str));
|
|
94
|
+
const TrainToTitle = (str) => DashToTitle(TrainToDash(str));
|
|
95
|
+
const TrainToSentence = (str) => DashToSentence(TrainToDash(str));
|
|
96
|
+
const DotToTitle = (str) => DashToTitle(DotToDash(str));
|
|
97
|
+
const DotToSentence = (str) => DashToSentence(DotToDash(str));
|
|
98
|
+
const TitleToDash = (str) => Lowercase(str).replace(/( )/g, "-");
|
|
99
|
+
const TitleToCamel = (str) => DashToCamel(TitleToDash(str));
|
|
100
|
+
const TitleToPascal = (str) => DashToPascal(TitleToDash(str));
|
|
101
|
+
const TitleToSnake = (str) => DashToSnake(TitleToDash(str));
|
|
102
|
+
const TitleToUpperSnake = (str) => DashToUpperSnake(TitleToDash(str));
|
|
103
|
+
const TitleToUpperDash = (str) => DashToUpperDash(TitleToDash(str));
|
|
104
|
+
const TitleToTrain = (str) => DashToTrain(TitleToDash(str));
|
|
105
|
+
const TitleToDot = (str) => DashToDot(TitleToDash(str));
|
|
106
|
+
const TitleToSentence = (str) => DashToSentence(TitleToDash(str));
|
|
107
|
+
const SentenceToDash = (str) => Lowercase(str).replace(/( )/g, "-");
|
|
108
|
+
const SentenceToCamel = (str) => DashToCamel(SentenceToDash(str));
|
|
109
|
+
const SentenceToPascal = (str) => DashToPascal(SentenceToDash(str));
|
|
110
|
+
const SentenceToSnake = (str) => DashToSnake(SentenceToDash(str));
|
|
111
|
+
const SentenceToUpperSnake = (str) => DashToUpperSnake(SentenceToDash(str));
|
|
112
|
+
const SentenceToUpperDash = (str) => DashToUpperDash(SentenceToDash(str));
|
|
113
|
+
const SentenceToTrain = (str) => DashToTrain(SentenceToDash(str));
|
|
114
|
+
const SentenceToDot = (str) => DashToDot(SentenceToDash(str));
|
|
115
|
+
const SentenceToTitle = (str) => DashToTitle(SentenceToDash(str));
|
|
82
116
|
function parse(input, type) {
|
|
83
117
|
return {
|
|
84
118
|
CamelToDash,
|
|
@@ -136,7 +170,41 @@ function parse(input, type) {
|
|
|
136
170
|
DotToDash,
|
|
137
171
|
DotToUpperSnake,
|
|
138
172
|
DotToUpperDash,
|
|
139
|
-
DotToTrain
|
|
173
|
+
DotToTrain,
|
|
174
|
+
CamelToTitle,
|
|
175
|
+
CamelToSentence,
|
|
176
|
+
PascalToTitle,
|
|
177
|
+
PascalToSentence,
|
|
178
|
+
SnakeToTitle,
|
|
179
|
+
SnakeToSentence,
|
|
180
|
+
DashToTitle,
|
|
181
|
+
DashToSentence,
|
|
182
|
+
UpperSnakeToTitle,
|
|
183
|
+
UpperSnakeToSentence,
|
|
184
|
+
UpperDashToTitle,
|
|
185
|
+
UpperDashToSentence,
|
|
186
|
+
TrainToTitle,
|
|
187
|
+
TrainToSentence,
|
|
188
|
+
DotToTitle,
|
|
189
|
+
DotToSentence,
|
|
190
|
+
TitleToCamel,
|
|
191
|
+
TitleToPascal,
|
|
192
|
+
TitleToSnake,
|
|
193
|
+
TitleToDash,
|
|
194
|
+
TitleToUpperSnake,
|
|
195
|
+
TitleToUpperDash,
|
|
196
|
+
TitleToTrain,
|
|
197
|
+
TitleToDot,
|
|
198
|
+
TitleToSentence,
|
|
199
|
+
SentenceToCamel,
|
|
200
|
+
SentenceToPascal,
|
|
201
|
+
SentenceToSnake,
|
|
202
|
+
SentenceToDash,
|
|
203
|
+
SentenceToUpperSnake,
|
|
204
|
+
SentenceToUpperDash,
|
|
205
|
+
SentenceToTrain,
|
|
206
|
+
SentenceToDot,
|
|
207
|
+
SentenceToTitle
|
|
140
208
|
}[type](input);
|
|
141
209
|
}
|
|
142
210
|
//#endregion
|
|
@@ -263,6 +331,30 @@ function camelToTrain(input) {
|
|
|
263
331
|
function camelToDot(input) {
|
|
264
332
|
return converter(input, "CamelToDot");
|
|
265
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to Title Case.
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```ts
|
|
339
|
+
* camelToTitle('helloWorld'); // 'Hello World'
|
|
340
|
+
* camelToTitle({ firstName: 'John' }); // { 'First Name': 'John' }
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
function camelToTitle(input) {
|
|
344
|
+
return converter(input, "CamelToTitle");
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to Sentence case.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```ts
|
|
351
|
+
* camelToSentence('helloWorld'); // 'Hello world'
|
|
352
|
+
* camelToSentence({ firstName: 'John' }); // { 'First name': 'John' }
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
function camelToSentence(input) {
|
|
356
|
+
return converter(input, "CamelToSentence");
|
|
357
|
+
}
|
|
266
358
|
//#endregion
|
|
267
359
|
//#region src/dashCase/dashCase.ts
|
|
268
360
|
/**
|
|
@@ -349,6 +441,30 @@ function dashToTrain(input) {
|
|
|
349
441
|
function dashToDot(input) {
|
|
350
442
|
return converter(input, "DashToDot");
|
|
351
443
|
}
|
|
444
|
+
/**
|
|
445
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to Title Case.
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* dashToTitle('hello-world'); // 'Hello World'
|
|
450
|
+
* dashToTitle({ 'first-name': 'John' }); // { 'First Name': 'John' }
|
|
451
|
+
* ```
|
|
452
|
+
*/
|
|
453
|
+
function dashToTitle(input) {
|
|
454
|
+
return converter(input, "DashToTitle");
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to Sentence case.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```ts
|
|
461
|
+
* dashToSentence('hello-world'); // 'Hello world'
|
|
462
|
+
* dashToSentence({ 'first-name': 'John' }); // { 'First name': 'John' }
|
|
463
|
+
* ```
|
|
464
|
+
*/
|
|
465
|
+
function dashToSentence(input) {
|
|
466
|
+
return converter(input, "DashToSentence");
|
|
467
|
+
}
|
|
352
468
|
//#endregion
|
|
353
469
|
//#region src/pascalCase/pascalCase.ts
|
|
354
470
|
/**
|
|
@@ -435,6 +551,30 @@ function pascalToTrain(input) {
|
|
|
435
551
|
function pascalToDot(input) {
|
|
436
552
|
return converter(input, "PascalToDot");
|
|
437
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to Title Case.
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* ```ts
|
|
559
|
+
* pascalToTitle('HelloWorld'); // 'Hello World'
|
|
560
|
+
* pascalToTitle({ FirstName: 'John' }); // { 'First Name': 'John' }
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
function pascalToTitle(input) {
|
|
564
|
+
return converter(input, "PascalToTitle");
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to Sentence case.
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```ts
|
|
571
|
+
* pascalToSentence('HelloWorld'); // 'Hello world'
|
|
572
|
+
* pascalToSentence({ FirstName: 'John' }); // { 'First name': 'John' }
|
|
573
|
+
* ```
|
|
574
|
+
*/
|
|
575
|
+
function pascalToSentence(input) {
|
|
576
|
+
return converter(input, "PascalToSentence");
|
|
577
|
+
}
|
|
438
578
|
//#endregion
|
|
439
579
|
//#region src/snakeCase/snakeCase.ts
|
|
440
580
|
/**
|
|
@@ -521,6 +661,30 @@ function snakeToTrain(input) {
|
|
|
521
661
|
function snakeToDot(input) {
|
|
522
662
|
return converter(input, "SnakeToDot");
|
|
523
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to Title Case.
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* ```ts
|
|
669
|
+
* snakeToTitle('hello_world'); // 'Hello World'
|
|
670
|
+
* snakeToTitle({ first_name: 'John' }); // { 'First Name': 'John' }
|
|
671
|
+
* ```
|
|
672
|
+
*/
|
|
673
|
+
function snakeToTitle(input) {
|
|
674
|
+
return converter(input, "SnakeToTitle");
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to Sentence case.
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* ```ts
|
|
681
|
+
* snakeToSentence('hello_world'); // 'Hello world'
|
|
682
|
+
* snakeToSentence({ first_name: 'John' }); // { 'First name': 'John' }
|
|
683
|
+
* ```
|
|
684
|
+
*/
|
|
685
|
+
function snakeToSentence(input) {
|
|
686
|
+
return converter(input, "SnakeToSentence");
|
|
687
|
+
}
|
|
524
688
|
//#endregion
|
|
525
689
|
//#region src/trainCase/trainCase.ts
|
|
526
690
|
/**
|
|
@@ -607,6 +771,30 @@ function trainToUpperDash(input) {
|
|
|
607
771
|
function trainToDot(input) {
|
|
608
772
|
return converter(input, "TrainToDot");
|
|
609
773
|
}
|
|
774
|
+
/**
|
|
775
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to Title Case.
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* ```ts
|
|
779
|
+
* trainToTitle('Hello-World'); // 'Hello World'
|
|
780
|
+
* trainToTitle({ 'First-Name': 'John' }); // { 'First Name': 'John' }
|
|
781
|
+
* ```
|
|
782
|
+
*/
|
|
783
|
+
function trainToTitle(input) {
|
|
784
|
+
return converter(input, "TrainToTitle");
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Converts a string, or the keys of an object/array (deeply), from Train-Case to Sentence case.
|
|
788
|
+
*
|
|
789
|
+
* @example
|
|
790
|
+
* ```ts
|
|
791
|
+
* trainToSentence('Hello-World'); // 'Hello world'
|
|
792
|
+
* trainToSentence({ 'First-Name': 'John' }); // { 'First name': 'John' }
|
|
793
|
+
* ```
|
|
794
|
+
*/
|
|
795
|
+
function trainToSentence(input) {
|
|
796
|
+
return converter(input, "TrainToSentence");
|
|
797
|
+
}
|
|
610
798
|
//#endregion
|
|
611
799
|
//#region src/dotCase/dotCase.ts
|
|
612
800
|
/**
|
|
@@ -693,6 +881,250 @@ function dotToUpperDash(input) {
|
|
|
693
881
|
function dotToTrain(input) {
|
|
694
882
|
return converter(input, "DotToTrain");
|
|
695
883
|
}
|
|
884
|
+
/**
|
|
885
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to Title Case.
|
|
886
|
+
*
|
|
887
|
+
* @example
|
|
888
|
+
* ```ts
|
|
889
|
+
* dotToTitle('hello.world'); // 'Hello World'
|
|
890
|
+
* dotToTitle({ 'first.name': 'John' }); // { 'First Name': 'John' }
|
|
891
|
+
* ```
|
|
892
|
+
*/
|
|
893
|
+
function dotToTitle(input) {
|
|
894
|
+
return converter(input, "DotToTitle");
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Converts a string, or the keys of an object/array (deeply), from dot.case to Sentence case.
|
|
898
|
+
*
|
|
899
|
+
* @example
|
|
900
|
+
* ```ts
|
|
901
|
+
* dotToSentence('hello.world'); // 'Hello world'
|
|
902
|
+
* dotToSentence({ 'first.name': 'John' }); // { 'First name': 'John' }
|
|
903
|
+
* ```
|
|
904
|
+
*/
|
|
905
|
+
function dotToSentence(input) {
|
|
906
|
+
return converter(input, "DotToSentence");
|
|
907
|
+
}
|
|
908
|
+
//#endregion
|
|
909
|
+
//#region src/titleCase/titleCase.ts
|
|
910
|
+
/**
|
|
911
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to camelCase.
|
|
912
|
+
*
|
|
913
|
+
* @example
|
|
914
|
+
* ```ts
|
|
915
|
+
* titleToCamel('Hello World'); // 'helloWorld'
|
|
916
|
+
* titleToCamel({ 'First Name': 'John' }); // { firstName: 'John' }
|
|
917
|
+
* ```
|
|
918
|
+
*/
|
|
919
|
+
function titleToCamel(input) {
|
|
920
|
+
return converter(input, "TitleToCamel");
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to PascalCase.
|
|
924
|
+
*
|
|
925
|
+
* @example
|
|
926
|
+
* ```ts
|
|
927
|
+
* titleToPascal('Hello World'); // 'HelloWorld'
|
|
928
|
+
* titleToPascal({ 'First Name': 'John' }); // { FirstName: 'John' }
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
function titleToPascal(input) {
|
|
932
|
+
return converter(input, "TitleToPascal");
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to snake_case.
|
|
936
|
+
*
|
|
937
|
+
* @example
|
|
938
|
+
* ```ts
|
|
939
|
+
* titleToSnake('Hello World'); // 'hello_world'
|
|
940
|
+
* titleToSnake({ 'First Name': 'John' }); // { first_name: 'John' }
|
|
941
|
+
* ```
|
|
942
|
+
*/
|
|
943
|
+
function titleToSnake(input) {
|
|
944
|
+
return converter(input, "TitleToSnake");
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to dash-case.
|
|
948
|
+
*
|
|
949
|
+
* @example
|
|
950
|
+
* ```ts
|
|
951
|
+
* titleToDash('Hello World'); // 'hello-world'
|
|
952
|
+
* titleToDash({ 'First Name': 'John' }); // { 'first-name': 'John' }
|
|
953
|
+
* ```
|
|
954
|
+
*/
|
|
955
|
+
function titleToDash(input) {
|
|
956
|
+
return converter(input, "TitleToDash");
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to UPPER_SNAKE_CASE.
|
|
960
|
+
*
|
|
961
|
+
* @example
|
|
962
|
+
* ```ts
|
|
963
|
+
* titleToUpperSnake('Hello World'); // 'HELLO_WORLD'
|
|
964
|
+
* titleToUpperSnake({ 'First Name': 'John' }); // { FIRST_NAME: 'John' }
|
|
965
|
+
* ```
|
|
966
|
+
*/
|
|
967
|
+
function titleToUpperSnake(input) {
|
|
968
|
+
return converter(input, "TitleToUpperSnake");
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to UPPER-DASH-CASE.
|
|
972
|
+
*
|
|
973
|
+
* @example
|
|
974
|
+
* ```ts
|
|
975
|
+
* titleToUpperDash('Hello World'); // 'HELLO-WORLD'
|
|
976
|
+
* titleToUpperDash({ 'First Name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
977
|
+
* ```
|
|
978
|
+
*/
|
|
979
|
+
function titleToUpperDash(input) {
|
|
980
|
+
return converter(input, "TitleToUpperDash");
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to Train-Case.
|
|
984
|
+
*
|
|
985
|
+
* @example
|
|
986
|
+
* ```ts
|
|
987
|
+
* titleToTrain('Hello World'); // 'Hello-World'
|
|
988
|
+
* titleToTrain({ 'First Name': 'John' }); // { 'First-Name': 'John' }
|
|
989
|
+
* ```
|
|
990
|
+
*/
|
|
991
|
+
function titleToTrain(input) {
|
|
992
|
+
return converter(input, "TitleToTrain");
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to dot.case.
|
|
996
|
+
*
|
|
997
|
+
* @example
|
|
998
|
+
* ```ts
|
|
999
|
+
* titleToDot('Hello World'); // 'hello.world'
|
|
1000
|
+
* titleToDot({ 'First Name': 'John' }); // { 'first.name': 'John' }
|
|
1001
|
+
* ```
|
|
1002
|
+
*/
|
|
1003
|
+
function titleToDot(input) {
|
|
1004
|
+
return converter(input, "TitleToDot");
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Converts a string, or the keys of an object/array (deeply), from Title Case to Sentence case.
|
|
1008
|
+
*
|
|
1009
|
+
* @example
|
|
1010
|
+
* ```ts
|
|
1011
|
+
* titleToSentence('Hello World'); // 'Hello world'
|
|
1012
|
+
* titleToSentence({ 'First Name': 'John' }); // { 'First name': 'John' }
|
|
1013
|
+
* ```
|
|
1014
|
+
*/
|
|
1015
|
+
function titleToSentence(input) {
|
|
1016
|
+
return converter(input, "TitleToSentence");
|
|
1017
|
+
}
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region src/sentenceCase/sentenceCase.ts
|
|
1020
|
+
/**
|
|
1021
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to camelCase.
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```ts
|
|
1025
|
+
* sentenceToCamel('Hello world'); // 'helloWorld'
|
|
1026
|
+
* sentenceToCamel({ 'First name': 'John' }); // { firstName: 'John' }
|
|
1027
|
+
* ```
|
|
1028
|
+
*/
|
|
1029
|
+
function sentenceToCamel(input) {
|
|
1030
|
+
return converter(input, "SentenceToCamel");
|
|
1031
|
+
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to PascalCase.
|
|
1034
|
+
*
|
|
1035
|
+
* @example
|
|
1036
|
+
* ```ts
|
|
1037
|
+
* sentenceToPascal('Hello world'); // 'HelloWorld'
|
|
1038
|
+
* sentenceToPascal({ 'First name': 'John' }); // { FirstName: 'John' }
|
|
1039
|
+
* ```
|
|
1040
|
+
*/
|
|
1041
|
+
function sentenceToPascal(input) {
|
|
1042
|
+
return converter(input, "SentenceToPascal");
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to snake_case.
|
|
1046
|
+
*
|
|
1047
|
+
* @example
|
|
1048
|
+
* ```ts
|
|
1049
|
+
* sentenceToSnake('Hello world'); // 'hello_world'
|
|
1050
|
+
* sentenceToSnake({ 'First name': 'John' }); // { first_name: 'John' }
|
|
1051
|
+
* ```
|
|
1052
|
+
*/
|
|
1053
|
+
function sentenceToSnake(input) {
|
|
1054
|
+
return converter(input, "SentenceToSnake");
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to dash-case.
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* ```ts
|
|
1061
|
+
* sentenceToDash('Hello world'); // 'hello-world'
|
|
1062
|
+
* sentenceToDash({ 'First name': 'John' }); // { 'first-name': 'John' }
|
|
1063
|
+
* ```
|
|
1064
|
+
*/
|
|
1065
|
+
function sentenceToDash(input) {
|
|
1066
|
+
return converter(input, "SentenceToDash");
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to UPPER_SNAKE_CASE.
|
|
1070
|
+
*
|
|
1071
|
+
* @example
|
|
1072
|
+
* ```ts
|
|
1073
|
+
* sentenceToUpperSnake('Hello world'); // 'HELLO_WORLD'
|
|
1074
|
+
* sentenceToUpperSnake({ 'First name': 'John' }); // { FIRST_NAME: 'John' }
|
|
1075
|
+
* ```
|
|
1076
|
+
*/
|
|
1077
|
+
function sentenceToUpperSnake(input) {
|
|
1078
|
+
return converter(input, "SentenceToUpperSnake");
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to UPPER-DASH-CASE.
|
|
1082
|
+
*
|
|
1083
|
+
* @example
|
|
1084
|
+
* ```ts
|
|
1085
|
+
* sentenceToUpperDash('Hello world'); // 'HELLO-WORLD'
|
|
1086
|
+
* sentenceToUpperDash({ 'First name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
1087
|
+
* ```
|
|
1088
|
+
*/
|
|
1089
|
+
function sentenceToUpperDash(input) {
|
|
1090
|
+
return converter(input, "SentenceToUpperDash");
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to Train-Case.
|
|
1094
|
+
*
|
|
1095
|
+
* @example
|
|
1096
|
+
* ```ts
|
|
1097
|
+
* sentenceToTrain('Hello world'); // 'Hello-World'
|
|
1098
|
+
* sentenceToTrain({ 'First name': 'John' }); // { 'First-Name': 'John' }
|
|
1099
|
+
* ```
|
|
1100
|
+
*/
|
|
1101
|
+
function sentenceToTrain(input) {
|
|
1102
|
+
return converter(input, "SentenceToTrain");
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to dot.case.
|
|
1106
|
+
*
|
|
1107
|
+
* @example
|
|
1108
|
+
* ```ts
|
|
1109
|
+
* sentenceToDot('Hello world'); // 'hello.world'
|
|
1110
|
+
* sentenceToDot({ 'First name': 'John' }); // { 'first.name': 'John' }
|
|
1111
|
+
* ```
|
|
1112
|
+
*/
|
|
1113
|
+
function sentenceToDot(input) {
|
|
1114
|
+
return converter(input, "SentenceToDot");
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Converts a string, or the keys of an object/array (deeply), from Sentence case to Title Case.
|
|
1118
|
+
*
|
|
1119
|
+
* @example
|
|
1120
|
+
* ```ts
|
|
1121
|
+
* sentenceToTitle('Hello world'); // 'Hello World'
|
|
1122
|
+
* sentenceToTitle({ 'First name': 'John' }); // { 'First Name': 'John' }
|
|
1123
|
+
* ```
|
|
1124
|
+
*/
|
|
1125
|
+
function sentenceToTitle(input) {
|
|
1126
|
+
return converter(input, "SentenceToTitle");
|
|
1127
|
+
}
|
|
696
1128
|
//#endregion
|
|
697
1129
|
//#region src/upperDashCase/upperDashCase.ts
|
|
698
1130
|
/**
|
|
@@ -779,6 +1211,30 @@ function upperDashToTrain(input) {
|
|
|
779
1211
|
function upperDashToDot(input) {
|
|
780
1212
|
return converter(input, "UpperDashToDot");
|
|
781
1213
|
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to Title Case.
|
|
1216
|
+
*
|
|
1217
|
+
* @example
|
|
1218
|
+
* ```ts
|
|
1219
|
+
* upperDashToTitle('HELLO-WORLD'); // 'Hello World'
|
|
1220
|
+
* upperDashToTitle({ 'FIRST-NAME': 'John' }); // { 'First Name': 'John' }
|
|
1221
|
+
* ```
|
|
1222
|
+
*/
|
|
1223
|
+
function upperDashToTitle(input) {
|
|
1224
|
+
return converter(input, "UpperDashToTitle");
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to Sentence case.
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
* ```ts
|
|
1231
|
+
* upperDashToSentence('HELLO-WORLD'); // 'Hello world'
|
|
1232
|
+
* upperDashToSentence({ 'FIRST-NAME': 'John' }); // { 'First name': 'John' }
|
|
1233
|
+
* ```
|
|
1234
|
+
*/
|
|
1235
|
+
function upperDashToSentence(input) {
|
|
1236
|
+
return converter(input, "UpperDashToSentence");
|
|
1237
|
+
}
|
|
782
1238
|
//#endregion
|
|
783
1239
|
//#region src/upperSnakeCase/upperSnakeCase.ts
|
|
784
1240
|
/**
|
|
@@ -865,60 +1321,118 @@ function upperSnakeToTrain(input) {
|
|
|
865
1321
|
function upperSnakeToDot(input) {
|
|
866
1322
|
return converter(input, "UpperSnakeToDot");
|
|
867
1323
|
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to Title Case.
|
|
1326
|
+
*
|
|
1327
|
+
* @example
|
|
1328
|
+
* ```ts
|
|
1329
|
+
* upperSnakeToTitle('HELLO_WORLD'); // 'Hello World'
|
|
1330
|
+
* upperSnakeToTitle({ FIRST_NAME: 'John' }); // { 'First Name': 'John' }
|
|
1331
|
+
* ```
|
|
1332
|
+
*/
|
|
1333
|
+
function upperSnakeToTitle(input) {
|
|
1334
|
+
return converter(input, "UpperSnakeToTitle");
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to Sentence case.
|
|
1338
|
+
*
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```ts
|
|
1341
|
+
* upperSnakeToSentence('HELLO_WORLD'); // 'Hello world'
|
|
1342
|
+
* upperSnakeToSentence({ FIRST_NAME: 'John' }); // { 'First name': 'John' }
|
|
1343
|
+
* ```
|
|
1344
|
+
*/
|
|
1345
|
+
function upperSnakeToSentence(input) {
|
|
1346
|
+
return converter(input, "UpperSnakeToSentence");
|
|
1347
|
+
}
|
|
868
1348
|
//#endregion
|
|
869
1349
|
exports.camelToDash = camelToDash;
|
|
870
1350
|
exports.camelToDot = camelToDot;
|
|
871
1351
|
exports.camelToPascal = camelToPascal;
|
|
1352
|
+
exports.camelToSentence = camelToSentence;
|
|
872
1353
|
exports.camelToSnake = camelToSnake;
|
|
1354
|
+
exports.camelToTitle = camelToTitle;
|
|
873
1355
|
exports.camelToTrain = camelToTrain;
|
|
874
1356
|
exports.camelToUpperDash = camelToUpperDash;
|
|
875
1357
|
exports.camelToUpperSnake = camelToUpperSnake;
|
|
876
1358
|
exports.dashToCamel = dashToCamel;
|
|
877
1359
|
exports.dashToDot = dashToDot;
|
|
878
1360
|
exports.dashToPascal = dashToPascal;
|
|
1361
|
+
exports.dashToSentence = dashToSentence;
|
|
879
1362
|
exports.dashToSnake = dashToSnake;
|
|
1363
|
+
exports.dashToTitle = dashToTitle;
|
|
880
1364
|
exports.dashToTrain = dashToTrain;
|
|
881
1365
|
exports.dashToUpperDash = dashToUpperDash;
|
|
882
1366
|
exports.dashToUpperSnake = dashToUpperSnake;
|
|
883
1367
|
exports.dotToCamel = dotToCamel;
|
|
884
1368
|
exports.dotToDash = dotToDash;
|
|
885
1369
|
exports.dotToPascal = dotToPascal;
|
|
1370
|
+
exports.dotToSentence = dotToSentence;
|
|
886
1371
|
exports.dotToSnake = dotToSnake;
|
|
1372
|
+
exports.dotToTitle = dotToTitle;
|
|
887
1373
|
exports.dotToTrain = dotToTrain;
|
|
888
1374
|
exports.dotToUpperDash = dotToUpperDash;
|
|
889
1375
|
exports.dotToUpperSnake = dotToUpperSnake;
|
|
890
1376
|
exports.pascalToCamel = pascalToCamel;
|
|
891
1377
|
exports.pascalToDash = pascalToDash;
|
|
892
1378
|
exports.pascalToDot = pascalToDot;
|
|
1379
|
+
exports.pascalToSentence = pascalToSentence;
|
|
893
1380
|
exports.pascalToSnake = pascalToSnake;
|
|
1381
|
+
exports.pascalToTitle = pascalToTitle;
|
|
894
1382
|
exports.pascalToTrain = pascalToTrain;
|
|
895
1383
|
exports.pascalToUpperDash = pascalToUpperDash;
|
|
896
1384
|
exports.pascalToUpperSnake = pascalToUpperSnake;
|
|
1385
|
+
exports.sentenceToCamel = sentenceToCamel;
|
|
1386
|
+
exports.sentenceToDash = sentenceToDash;
|
|
1387
|
+
exports.sentenceToDot = sentenceToDot;
|
|
1388
|
+
exports.sentenceToPascal = sentenceToPascal;
|
|
1389
|
+
exports.sentenceToSnake = sentenceToSnake;
|
|
1390
|
+
exports.sentenceToTitle = sentenceToTitle;
|
|
1391
|
+
exports.sentenceToTrain = sentenceToTrain;
|
|
1392
|
+
exports.sentenceToUpperDash = sentenceToUpperDash;
|
|
1393
|
+
exports.sentenceToUpperSnake = sentenceToUpperSnake;
|
|
897
1394
|
exports.snakeToCamel = snakeToCamel;
|
|
898
1395
|
exports.snakeToDash = snakeToDash;
|
|
899
1396
|
exports.snakeToDot = snakeToDot;
|
|
900
1397
|
exports.snakeToPascal = snakeToPascal;
|
|
1398
|
+
exports.snakeToSentence = snakeToSentence;
|
|
1399
|
+
exports.snakeToTitle = snakeToTitle;
|
|
901
1400
|
exports.snakeToTrain = snakeToTrain;
|
|
902
1401
|
exports.snakeToUpperDash = snakeToUpperDash;
|
|
903
1402
|
exports.snakeToUpperSnake = snakeToUpperSnake;
|
|
1403
|
+
exports.titleToCamel = titleToCamel;
|
|
1404
|
+
exports.titleToDash = titleToDash;
|
|
1405
|
+
exports.titleToDot = titleToDot;
|
|
1406
|
+
exports.titleToPascal = titleToPascal;
|
|
1407
|
+
exports.titleToSentence = titleToSentence;
|
|
1408
|
+
exports.titleToSnake = titleToSnake;
|
|
1409
|
+
exports.titleToTrain = titleToTrain;
|
|
1410
|
+
exports.titleToUpperDash = titleToUpperDash;
|
|
1411
|
+
exports.titleToUpperSnake = titleToUpperSnake;
|
|
904
1412
|
exports.trainToCamel = trainToCamel;
|
|
905
1413
|
exports.trainToDash = trainToDash;
|
|
906
1414
|
exports.trainToDot = trainToDot;
|
|
907
1415
|
exports.trainToPascal = trainToPascal;
|
|
1416
|
+
exports.trainToSentence = trainToSentence;
|
|
908
1417
|
exports.trainToSnake = trainToSnake;
|
|
1418
|
+
exports.trainToTitle = trainToTitle;
|
|
909
1419
|
exports.trainToUpperDash = trainToUpperDash;
|
|
910
1420
|
exports.trainToUpperSnake = trainToUpperSnake;
|
|
911
1421
|
exports.upperDashToCamel = upperDashToCamel;
|
|
912
1422
|
exports.upperDashToDash = upperDashToDash;
|
|
913
1423
|
exports.upperDashToDot = upperDashToDot;
|
|
914
1424
|
exports.upperDashToPascal = upperDashToPascal;
|
|
1425
|
+
exports.upperDashToSentence = upperDashToSentence;
|
|
915
1426
|
exports.upperDashToSnake = upperDashToSnake;
|
|
1427
|
+
exports.upperDashToTitle = upperDashToTitle;
|
|
916
1428
|
exports.upperDashToTrain = upperDashToTrain;
|
|
917
1429
|
exports.upperDashToUpperSnake = upperDashToUpperSnake;
|
|
918
1430
|
exports.upperSnakeToCamel = upperSnakeToCamel;
|
|
919
1431
|
exports.upperSnakeToDash = upperSnakeToDash;
|
|
920
1432
|
exports.upperSnakeToDot = upperSnakeToDot;
|
|
921
1433
|
exports.upperSnakeToPascal = upperSnakeToPascal;
|
|
1434
|
+
exports.upperSnakeToSentence = upperSnakeToSentence;
|
|
922
1435
|
exports.upperSnakeToSnake = upperSnakeToSnake;
|
|
1436
|
+
exports.upperSnakeToTitle = upperSnakeToTitle;
|
|
923
1437
|
exports.upperSnakeToTrain = upperSnakeToTrain;
|
|
924
1438
|
exports.upperSnakeToUpperDash = upperSnakeToUpperDash;
|