caseparser 3.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 +110 -135
- package/dist/index.cjs +924 -0
- package/dist/index.d.cts +652 -0
- package/dist/index.d.ts +624 -48
- package/dist/index.js +821 -271
- package/package.json +52 -23
- package/.nvmrc +0 -1
- package/CHANGELOG.md +0 -40
- package/dist/index.mjs +0 -262
package/dist/index.js
CHANGED
|
@@ -1,318 +1,868 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
camelToDash: () => camelToDash,
|
|
24
|
-
camelToPascal: () => camelToPascal,
|
|
25
|
-
camelToSnake: () => camelToSnake,
|
|
26
|
-
camelToUpperDash: () => camelToUpperDash,
|
|
27
|
-
camelToUpperSnake: () => camelToUpperSnake,
|
|
28
|
-
dashToCamel: () => dashToCamel,
|
|
29
|
-
dashToPascal: () => dashToPascal,
|
|
30
|
-
dashToSnake: () => dashToSnake,
|
|
31
|
-
dashToUpperDash: () => dashToUpperDash,
|
|
32
|
-
dashToUpperSnake: () => dashToUpperSnake,
|
|
33
|
-
pascalToCamel: () => pascalToCamel,
|
|
34
|
-
pascalToDash: () => pascalToDash,
|
|
35
|
-
pascalToSnake: () => pascalToSnake,
|
|
36
|
-
pascalToUpperDash: () => pascalToUpperDash,
|
|
37
|
-
pascalToUpperSnake: () => pascalToUpperSnake,
|
|
38
|
-
snakeToCamel: () => snakeToCamel,
|
|
39
|
-
snakeToDash: () => snakeToDash,
|
|
40
|
-
snakeToPascal: () => snakeToPascal,
|
|
41
|
-
snakeToUpperDash: () => snakeToUpperDash,
|
|
42
|
-
snakeToUpperSnake: () => snakeToUpperSnake,
|
|
43
|
-
upperDashToCamel: () => upperDashToCamel,
|
|
44
|
-
upperDashToDash: () => upperDashToDash,
|
|
45
|
-
upperDashToPascal: () => upperDashToPascal,
|
|
46
|
-
upperDashToSnake: () => upperDashToSnake,
|
|
47
|
-
upperDashToUpperSnake: () => upperDashToUpperSnake,
|
|
48
|
-
upperSnakeToCamel: () => upperSnakeToCamel,
|
|
49
|
-
upperSnakeToDash: () => upperSnakeToDash,
|
|
50
|
-
upperSnakeToPascal: () => upperSnakeToPascal,
|
|
51
|
-
upperSnakeToSnake: () => upperSnakeToSnake,
|
|
52
|
-
upperSnakeToUpperDash: () => upperSnakeToUpperDash
|
|
53
|
-
});
|
|
54
|
-
module.exports = __toCommonJS(src_exports);
|
|
55
|
-
|
|
56
|
-
// src/utils.ts
|
|
1
|
+
//#region src/utils.ts
|
|
57
2
|
function isString(input) {
|
|
58
|
-
|
|
3
|
+
return typeof input === "string";
|
|
59
4
|
}
|
|
60
5
|
function isObject(input) {
|
|
61
|
-
|
|
6
|
+
return typeof input === "object" && (input === null || input === void 0 ? void 0 : input.constructor) === Object;
|
|
62
7
|
}
|
|
63
8
|
function isArray(input) {
|
|
64
|
-
|
|
9
|
+
return Array.isArray(input);
|
|
65
10
|
}
|
|
66
11
|
function Lowercase(str) {
|
|
67
|
-
|
|
12
|
+
return str.toLowerCase();
|
|
68
13
|
}
|
|
69
14
|
function Uppercase(str) {
|
|
70
|
-
|
|
15
|
+
return str.toUpperCase();
|
|
71
16
|
}
|
|
72
17
|
function Capitalize(str) {
|
|
73
|
-
|
|
18
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
74
19
|
}
|
|
75
20
|
function Uncapitalize(str) {
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
21
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/parser/stringParser.ts
|
|
25
|
+
const CamelToDash = (str) => str.replace(/([A-Z])/g, (g) => "-" + g[0].toLowerCase());
|
|
26
|
+
const CamelToPascal = (str) => Capitalize(str);
|
|
27
|
+
const CamelToSnake = (str) => str.replace(/([A-Z])/g, (g) => "_" + g[0].toLowerCase());
|
|
28
|
+
const CamelToUpperDash = (str) => Uppercase(CamelToDash(str));
|
|
29
|
+
const CamelToUpperSnake = (str) => Uppercase(CamelToSnake(str));
|
|
30
|
+
const CamelToTrain = (str) => DashToTrain(CamelToDash(str));
|
|
31
|
+
const CamelToDot = (str) => DashToDot(CamelToDash(str));
|
|
32
|
+
const DashToCamel = (str) => str.replace(/(\-\w)/g, (g) => g[1].toUpperCase());
|
|
33
|
+
const DashToPascal = (str) => Capitalize(DashToCamel(str));
|
|
34
|
+
const DashToSnake = (str) => str.replace(/(\-)/g, "_");
|
|
35
|
+
const DashToUpperDash = (str) => Uppercase(str);
|
|
36
|
+
const DashToUpperSnake = (str) => Uppercase(DashToSnake(str));
|
|
37
|
+
const DashToTrain = (str) => str.split("-").map(Capitalize).join("-");
|
|
38
|
+
const DashToDot = (str) => str.replace(/(\-)/g, ".");
|
|
39
|
+
const PascalToCamel = (str) => Uncapitalize(str);
|
|
40
|
+
const PascalToDash = (str) => CamelToDash(Uncapitalize(str));
|
|
41
|
+
const PascalToSnake = (str) => CamelToSnake(Uncapitalize(str));
|
|
42
|
+
const PascalToUpperDash = (str) => Uppercase(PascalToDash(str));
|
|
43
|
+
const PascalToUpperSnake = (str) => Uppercase(PascalToSnake(str));
|
|
44
|
+
const PascalToTrain = (str) => DashToTrain(PascalToDash(str));
|
|
45
|
+
const PascalToDot = (str) => DashToDot(PascalToDash(str));
|
|
46
|
+
const SnakeToCamel = (str) => str.replace(/(\_\w)/g, (g) => g[1].toUpperCase());
|
|
47
|
+
const SnakeToDash = (str) => str.replace(/(\_)/g, "-");
|
|
48
|
+
const SnakeToPascal = (str) => Capitalize(SnakeToCamel(str));
|
|
49
|
+
const SnakeToUpperDash = (str) => Uppercase(SnakeToDash(str));
|
|
50
|
+
const SnakeToTrain = (str) => DashToTrain(SnakeToDash(str));
|
|
51
|
+
const SnakeToDot = (str) => DashToDot(SnakeToDash(str));
|
|
52
|
+
const SnakeToUpperSnake = (str) => Uppercase(str);
|
|
53
|
+
const UpperDashToCamel = (str) => DashToCamel(Lowercase(str));
|
|
54
|
+
const UpperDashToDash = (str) => Lowercase(str);
|
|
55
|
+
const UpperDashToPascal = (str) => Capitalize(UpperDashToCamel(str));
|
|
56
|
+
const UpperDashToSnake = (str) => DashToSnake(UpperDashToDash(str));
|
|
57
|
+
const UpperDashToUpperSnake = (str) => Uppercase(UpperDashToSnake(str));
|
|
58
|
+
const UpperDashToTrain = (str) => DashToTrain(UpperDashToDash(str));
|
|
59
|
+
const UpperDashToDot = (str) => DashToDot(UpperDashToDash(str));
|
|
60
|
+
const UpperSnakeToCamel = (str) => SnakeToCamel(Lowercase(str));
|
|
61
|
+
const UpperSnakeToDash = (str) => str.replace(/(\_)/g, "-").toLowerCase();
|
|
62
|
+
const UpperSnakeToPascal = (str) => SnakeToPascal(Lowercase(str));
|
|
63
|
+
const UpperSnakeToSnake = (str) => Lowercase(str);
|
|
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));
|
|
110
81
|
function parse(input, type) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
82
|
+
return {
|
|
83
|
+
CamelToDash,
|
|
84
|
+
CamelToPascal,
|
|
85
|
+
CamelToSnake,
|
|
86
|
+
CamelToUpperDash,
|
|
87
|
+
CamelToUpperSnake,
|
|
88
|
+
DashToCamel,
|
|
89
|
+
DashToSnake,
|
|
90
|
+
DashToPascal,
|
|
91
|
+
DashToUpperSnake,
|
|
92
|
+
DashToUpperDash,
|
|
93
|
+
PascalToCamel,
|
|
94
|
+
PascalToSnake,
|
|
95
|
+
PascalToDash,
|
|
96
|
+
PascalToUpperSnake,
|
|
97
|
+
PascalToUpperDash,
|
|
98
|
+
SnakeToCamel,
|
|
99
|
+
SnakeToDash,
|
|
100
|
+
SnakeToPascal,
|
|
101
|
+
SnakeToUpperSnake,
|
|
102
|
+
SnakeToUpperDash,
|
|
103
|
+
UpperSnakeToCamel,
|
|
104
|
+
UpperSnakeToSnake,
|
|
105
|
+
UpperSnakeToDash,
|
|
106
|
+
UpperSnakeToPascal,
|
|
107
|
+
UpperSnakeToUpperDash,
|
|
108
|
+
UpperDashToCamel,
|
|
109
|
+
UpperDashToSnake,
|
|
110
|
+
UpperDashToDash,
|
|
111
|
+
UpperDashToPascal,
|
|
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
|
|
139
|
+
}[type](input);
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/parser/objectParser.ts
|
|
146
143
|
function objectParser(input, type) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
144
|
+
const result = {};
|
|
145
|
+
for (const property of Object.keys(input)) {
|
|
146
|
+
const parsedKey = parse(property, type);
|
|
147
|
+
const value = input[property];
|
|
148
|
+
let parsedValue;
|
|
149
|
+
if (isArray(value)) parsedValue = arrayParser(value, type);
|
|
150
|
+
else if (isObject(value)) parsedValue = objectParser(value, type);
|
|
151
|
+
else parsedValue = value;
|
|
152
|
+
Object.defineProperty(result, parsedKey, {
|
|
153
|
+
value: parsedValue,
|
|
154
|
+
enumerable: true,
|
|
155
|
+
writable: true,
|
|
156
|
+
configurable: true
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/parser/arrayParser.ts
|
|
163
163
|
function arrayParser(input, type) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// src/parser/parser.ts
|
|
164
|
+
return input.map((item) => {
|
|
165
|
+
if (isArray(item)) return arrayParser(item, type);
|
|
166
|
+
if (isObject(item)) return objectParser(item, type);
|
|
167
|
+
return item;
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/parser/parser.ts
|
|
174
172
|
function converter(input, type) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
173
|
+
let result;
|
|
174
|
+
if (isString(input)) result = parse(input, type);
|
|
175
|
+
if (isArray(input)) result = arrayParser(input, type);
|
|
176
|
+
if (isObject(input)) result = objectParser(input, type);
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/camelCase/camelCase.ts
|
|
181
|
+
/**
|
|
182
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to dash-case.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* camelToDash('helloWorld'); // 'hello-world'
|
|
187
|
+
* camelToDash({ firstName: 'John' }); // { 'first-name': 'John' }
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
186
190
|
function camelToDash(input) {
|
|
187
|
-
|
|
188
|
-
}
|
|
191
|
+
return converter(input, "CamelToDash");
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to snake_case.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* camelToSnake('helloWorld'); // 'hello_world'
|
|
199
|
+
* camelToSnake({ firstName: 'John' }); // { first_name: 'John' }
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
189
202
|
function camelToSnake(input) {
|
|
190
|
-
|
|
191
|
-
}
|
|
203
|
+
return converter(input, "CamelToSnake");
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to PascalCase.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* camelToPascal('helloWorld'); // 'HelloWorld'
|
|
211
|
+
* camelToPascal({ firstName: 'John' }); // { FirstName: 'John' }
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
192
214
|
function camelToPascal(input) {
|
|
193
|
-
|
|
194
|
-
}
|
|
215
|
+
return converter(input, "CamelToPascal");
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to UPPER_SNAKE_CASE.
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```ts
|
|
222
|
+
* camelToUpperSnake('helloWorld'); // 'HELLO_WORLD'
|
|
223
|
+
* camelToUpperSnake({ firstName: 'John' }); // { FIRST_NAME: 'John' }
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
195
226
|
function camelToUpperSnake(input) {
|
|
196
|
-
|
|
197
|
-
}
|
|
227
|
+
return converter(input, "CamelToUpperSnake");
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to UPPER-DASH-CASE.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```ts
|
|
234
|
+
* camelToUpperDash('helloWorld'); // 'HELLO-WORLD'
|
|
235
|
+
* camelToUpperDash({ firstName: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
198
238
|
function camelToUpperDash(input) {
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
239
|
+
return converter(input, "CamelToUpperDash");
|
|
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
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/dashCase/dashCase.ts
|
|
267
|
+
/**
|
|
268
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to snake_case.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* dashToSnake('hello-world'); // 'hello_world'
|
|
273
|
+
* dashToSnake({ 'first-name': 'John' }); // { first_name: 'John' }
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
203
276
|
function dashToSnake(input) {
|
|
204
|
-
|
|
205
|
-
}
|
|
277
|
+
return converter(input, "DashToSnake");
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to camelCase.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```ts
|
|
284
|
+
* dashToCamel('hello-world'); // 'helloWorld'
|
|
285
|
+
* dashToCamel({ 'first-name': 'John' }); // { firstName: 'John' }
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
206
288
|
function dashToCamel(input) {
|
|
207
|
-
|
|
208
|
-
}
|
|
289
|
+
return converter(input, "DashToCamel");
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to PascalCase.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* dashToPascal('hello-world'); // 'HelloWorld'
|
|
297
|
+
* dashToPascal({ 'first-name': 'John' }); // { FirstName: 'John' }
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
209
300
|
function dashToPascal(input) {
|
|
210
|
-
|
|
211
|
-
}
|
|
301
|
+
return converter(input, "DashToPascal");
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to UPPER_SNAKE_CASE.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```ts
|
|
308
|
+
* dashToUpperSnake('hello-world'); // 'HELLO_WORLD'
|
|
309
|
+
* dashToUpperSnake({ 'first-name': 'John' }); // { FIRST_NAME: 'John' }
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
212
312
|
function dashToUpperSnake(input) {
|
|
213
|
-
|
|
214
|
-
}
|
|
313
|
+
return converter(input, "DashToUpperSnake");
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to UPPER-DASH-CASE.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```ts
|
|
320
|
+
* dashToUpperDash('hello-world'); // 'HELLO-WORLD'
|
|
321
|
+
* dashToUpperDash({ 'first-name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
215
324
|
function dashToUpperDash(input) {
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
325
|
+
return converter(input, "DashToUpperDash");
|
|
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
|
+
}
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/pascalCase/pascalCase.ts
|
|
353
|
+
/**
|
|
354
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to camelCase.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```ts
|
|
358
|
+
* pascalToCamel('HelloWorld'); // 'helloWorld'
|
|
359
|
+
* pascalToCamel({ FirstName: 'John' }); // { firstName: 'John' }
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
220
362
|
function pascalToCamel(input) {
|
|
221
|
-
|
|
222
|
-
}
|
|
363
|
+
return converter(input, "PascalToCamel");
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to snake_case.
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts
|
|
370
|
+
* pascalToSnake('HelloWorld'); // 'hello_world'
|
|
371
|
+
* pascalToSnake({ FirstName: 'John' }); // { first_name: 'John' }
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
223
374
|
function pascalToSnake(input) {
|
|
224
|
-
|
|
225
|
-
}
|
|
375
|
+
return converter(input, "PascalToSnake");
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to dash-case.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```ts
|
|
382
|
+
* pascalToDash('HelloWorld'); // 'hello-world'
|
|
383
|
+
* pascalToDash({ FirstName: 'John' }); // { 'first-name': 'John' }
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
226
386
|
function pascalToDash(input) {
|
|
227
|
-
|
|
228
|
-
}
|
|
387
|
+
return converter(input, "PascalToDash");
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to UPPER_SNAKE_CASE.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* pascalToUpperSnake('HelloWorld'); // 'HELLO_WORLD'
|
|
395
|
+
* pascalToUpperSnake({ FirstName: 'John' }); // { FIRST_NAME: 'John' }
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
229
398
|
function pascalToUpperSnake(input) {
|
|
230
|
-
|
|
231
|
-
}
|
|
399
|
+
return converter(input, "PascalToUpperSnake");
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to UPPER-DASH-CASE.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```ts
|
|
406
|
+
* pascalToUpperDash('HelloWorld'); // 'HELLO-WORLD'
|
|
407
|
+
* pascalToUpperDash({ FirstName: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
232
410
|
function pascalToUpperDash(input) {
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
411
|
+
return converter(input, "PascalToUpperDash");
|
|
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
|
+
}
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/snakeCase/snakeCase.ts
|
|
439
|
+
/**
|
|
440
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to camelCase.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* snakeToCamel('hello_world'); // 'helloWorld'
|
|
445
|
+
* snakeToCamel({ first_name: 'John' }); // { firstName: 'John' }
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
237
448
|
function snakeToCamel(input) {
|
|
238
|
-
|
|
239
|
-
}
|
|
449
|
+
return converter(input, "SnakeToCamel");
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to dash-case.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```ts
|
|
456
|
+
* snakeToDash('hello_world'); // 'hello-world'
|
|
457
|
+
* snakeToDash({ first_name: 'John' }); // { 'first-name': 'John' }
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
240
460
|
function snakeToDash(input) {
|
|
241
|
-
|
|
242
|
-
}
|
|
461
|
+
return converter(input, "SnakeToDash");
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to PascalCase.
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```ts
|
|
468
|
+
* snakeToPascal('hello_world'); // 'HelloWorld'
|
|
469
|
+
* snakeToPascal({ first_name: 'John' }); // { FirstName: 'John' }
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
243
472
|
function snakeToPascal(input) {
|
|
244
|
-
|
|
245
|
-
}
|
|
473
|
+
return converter(input, "SnakeToPascal");
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to UPPER_SNAKE_CASE.
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```ts
|
|
480
|
+
* snakeToUpperSnake('hello_world'); // 'HELLO_WORLD'
|
|
481
|
+
* snakeToUpperSnake({ first_name: 'John' }); // { FIRST_NAME: 'John' }
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
246
484
|
function snakeToUpperSnake(input) {
|
|
247
|
-
|
|
248
|
-
}
|
|
485
|
+
return converter(input, "SnakeToUpperSnake");
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to UPPER-DASH-CASE.
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```ts
|
|
492
|
+
* snakeToUpperDash('hello_world'); // 'HELLO-WORLD'
|
|
493
|
+
* snakeToUpperDash({ first_name: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
249
496
|
function snakeToUpperDash(input) {
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
497
|
+
return converter(input, "SnakeToUpperDash");
|
|
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
|
+
}
|
|
695
|
+
//#endregion
|
|
696
|
+
//#region src/upperDashCase/upperDashCase.ts
|
|
697
|
+
/**
|
|
698
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to camelCase.
|
|
699
|
+
*
|
|
700
|
+
* @example
|
|
701
|
+
* ```ts
|
|
702
|
+
* upperDashToCamel('HELLO-WORLD'); // 'helloWorld'
|
|
703
|
+
* upperDashToCamel({ 'FIRST-NAME': 'John' }); // { firstName: 'John' }
|
|
704
|
+
* ```
|
|
705
|
+
*/
|
|
254
706
|
function upperDashToCamel(input) {
|
|
255
|
-
|
|
256
|
-
}
|
|
707
|
+
return converter(input, "UpperDashToCamel");
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to snake_case.
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
* ```ts
|
|
714
|
+
* upperDashToSnake('HELLO-WORLD'); // 'hello_world'
|
|
715
|
+
* upperDashToSnake({ 'FIRST-NAME': 'John' }); // { first_name: 'John' }
|
|
716
|
+
* ```
|
|
717
|
+
*/
|
|
257
718
|
function upperDashToSnake(input) {
|
|
258
|
-
|
|
259
|
-
}
|
|
719
|
+
return converter(input, "UpperDashToSnake");
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to dash-case.
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```ts
|
|
726
|
+
* upperDashToDash('HELLO-WORLD'); // 'hello-world'
|
|
727
|
+
* upperDashToDash({ 'FIRST-NAME': 'John' }); // { 'first-name': 'John' }
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
260
730
|
function upperDashToDash(input) {
|
|
261
|
-
|
|
262
|
-
}
|
|
731
|
+
return converter(input, "UpperDashToDash");
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to PascalCase.
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
* ```ts
|
|
738
|
+
* upperDashToPascal('HELLO-WORLD'); // 'HelloWorld'
|
|
739
|
+
* upperDashToPascal({ 'FIRST-NAME': 'John' }); // { FirstName: 'John' }
|
|
740
|
+
* ```
|
|
741
|
+
*/
|
|
263
742
|
function upperDashToPascal(input) {
|
|
264
|
-
|
|
265
|
-
}
|
|
743
|
+
return converter(input, "UpperDashToPascal");
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to UPPER_SNAKE_CASE.
|
|
747
|
+
*
|
|
748
|
+
* @example
|
|
749
|
+
* ```ts
|
|
750
|
+
* upperDashToUpperSnake('HELLO-WORLD'); // 'HELLO_WORLD'
|
|
751
|
+
* upperDashToUpperSnake({ 'FIRST-NAME': 'John' }); // { FIRST_NAME: 'John' }
|
|
752
|
+
* ```
|
|
753
|
+
*/
|
|
266
754
|
function upperDashToUpperSnake(input) {
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
755
|
+
return converter(input, "UpperDashToUpperSnake");
|
|
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
|
+
}
|
|
781
|
+
//#endregion
|
|
782
|
+
//#region src/upperSnakeCase/upperSnakeCase.ts
|
|
783
|
+
/**
|
|
784
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to camelCase.
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* ```ts
|
|
788
|
+
* upperSnakeToCamel('HELLO_WORLD'); // 'helloWorld'
|
|
789
|
+
* upperSnakeToCamel({ FIRST_NAME: 'John' }); // { firstName: 'John' }
|
|
790
|
+
* ```
|
|
791
|
+
*/
|
|
271
792
|
function upperSnakeToCamel(input) {
|
|
272
|
-
|
|
273
|
-
}
|
|
793
|
+
return converter(input, "UpperSnakeToCamel");
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to snake_case.
|
|
797
|
+
*
|
|
798
|
+
* @example
|
|
799
|
+
* ```ts
|
|
800
|
+
* upperSnakeToSnake('HELLO_WORLD'); // 'hello_world'
|
|
801
|
+
* upperSnakeToSnake({ FIRST_NAME: 'John' }); // { first_name: 'John' }
|
|
802
|
+
* ```
|
|
803
|
+
*/
|
|
274
804
|
function upperSnakeToSnake(input) {
|
|
275
|
-
|
|
276
|
-
}
|
|
805
|
+
return converter(input, "UpperSnakeToSnake");
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to dash-case.
|
|
809
|
+
*
|
|
810
|
+
* @example
|
|
811
|
+
* ```ts
|
|
812
|
+
* upperSnakeToDash('HELLO_WORLD'); // 'hello-world'
|
|
813
|
+
* upperSnakeToDash({ FIRST_NAME: 'John' }); // { 'first-name': 'John' }
|
|
814
|
+
* ```
|
|
815
|
+
*/
|
|
277
816
|
function upperSnakeToDash(input) {
|
|
278
|
-
|
|
279
|
-
}
|
|
817
|
+
return converter(input, "UpperSnakeToDash");
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to PascalCase.
|
|
821
|
+
*
|
|
822
|
+
* @example
|
|
823
|
+
* ```ts
|
|
824
|
+
* upperSnakeToPascal('HELLO_WORLD'); // 'HelloWorld'
|
|
825
|
+
* upperSnakeToPascal({ FIRST_NAME: 'John' }); // { FirstName: 'John' }
|
|
826
|
+
* ```
|
|
827
|
+
*/
|
|
280
828
|
function upperSnakeToPascal(input) {
|
|
281
|
-
|
|
282
|
-
}
|
|
829
|
+
return converter(input, "UpperSnakeToPascal");
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to UPPER-DASH-CASE.
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* ```ts
|
|
836
|
+
* upperSnakeToUpperDash('HELLO_WORLD'); // 'HELLO-WORLD'
|
|
837
|
+
* upperSnakeToUpperDash({ FIRST_NAME: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
838
|
+
* ```
|
|
839
|
+
*/
|
|
283
840
|
function upperSnakeToUpperDash(input) {
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
upperDashToUpperSnake,
|
|
313
|
-
upperSnakeToCamel,
|
|
314
|
-
upperSnakeToDash,
|
|
315
|
-
upperSnakeToPascal,
|
|
316
|
-
upperSnakeToSnake,
|
|
317
|
-
upperSnakeToUpperDash
|
|
318
|
-
});
|
|
841
|
+
return converter(input, "UpperSnakeToUpperDash");
|
|
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
|
+
}
|
|
867
|
+
//#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 };
|