caseparser 2.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -36
- package/dist/index.cjs +530 -0
- package/dist/index.d.cts +360 -0
- package/dist/index.d.ts +332 -45
- package/dist/index.js +453 -279
- package/package.json +43 -22
- package/.nvmrc +0 -1
- package/CHANGELOG.md +0 -31
- package/dist/index.mjs +0 -309
package/dist/index.js
CHANGED
|
@@ -1,326 +1,500 @@
|
|
|
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
|
-
default: () => src_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(src_exports);
|
|
26
|
-
|
|
27
|
-
// src/camelCase/index.ts
|
|
28
|
-
var camelCase_exports = {};
|
|
29
|
-
__export(camelCase_exports, {
|
|
30
|
-
camelToDash: () => camelToDash,
|
|
31
|
-
camelToPascal: () => camelToPascal,
|
|
32
|
-
camelToSnake: () => camelToSnake,
|
|
33
|
-
camelToUpperDash: () => camelToUpperDash,
|
|
34
|
-
camelToUpperSnake: () => camelToUpperSnake
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// src/utils.ts
|
|
1
|
+
//#region src/utils.ts
|
|
38
2
|
function isString(input) {
|
|
39
|
-
|
|
3
|
+
return typeof input === "string";
|
|
40
4
|
}
|
|
41
5
|
function isObject(input) {
|
|
42
|
-
|
|
6
|
+
return typeof input === "object" && (input === null || input === void 0 ? void 0 : input.constructor) === Object;
|
|
43
7
|
}
|
|
44
8
|
function isArray(input) {
|
|
45
|
-
|
|
9
|
+
return Array.isArray(input);
|
|
46
10
|
}
|
|
47
11
|
function Lowercase(str) {
|
|
48
|
-
|
|
12
|
+
return str.toLowerCase();
|
|
49
13
|
}
|
|
50
14
|
function Uppercase(str) {
|
|
51
|
-
|
|
15
|
+
return str.toUpperCase();
|
|
52
16
|
}
|
|
53
17
|
function Capitalize(str) {
|
|
54
|
-
|
|
18
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
55
19
|
}
|
|
56
20
|
function Uncapitalize(str) {
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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 DashToCamel = (str) => str.replace(/(\-\w)/g, (g) => g[1].toUpperCase());
|
|
31
|
+
const DashToPascal = (str) => Capitalize(DashToCamel(str));
|
|
32
|
+
const DashToSnake = (str) => str.replace(/(\-)/g, "_");
|
|
33
|
+
const DashToUpperDash = (str) => Uppercase(str);
|
|
34
|
+
const DashToUpperSnake = (str) => Uppercase(DashToSnake(str));
|
|
35
|
+
const PascalToCamel = (str) => Uncapitalize(str);
|
|
36
|
+
const PascalToDash = (str) => CamelToDash(Uncapitalize(str));
|
|
37
|
+
const PascalToSnake = (str) => CamelToSnake(Uncapitalize(str));
|
|
38
|
+
const PascalToUpperDash = (str) => Uppercase(PascalToDash(str));
|
|
39
|
+
const PascalToUpperSnake = (str) => Uppercase(PascalToSnake(str));
|
|
40
|
+
const SnakeToCamel = (str) => str.replace(/(\_\w)/g, (g) => g[1].toUpperCase());
|
|
41
|
+
const SnakeToDash = (str) => str.replace(/(\_)/g, "-");
|
|
42
|
+
const SnakeToPascal = (str) => Capitalize(SnakeToCamel(str));
|
|
43
|
+
const SnakeToUpperDash = (str) => Uppercase(SnakeToDash(str));
|
|
44
|
+
const SnakeToUpperSnake = (str) => Uppercase(str);
|
|
45
|
+
const UpperDashToCamel = (str) => DashToCamel(Lowercase(str));
|
|
46
|
+
const UpperDashToDash = (str) => Lowercase(str);
|
|
47
|
+
const UpperDashToPascal = (str) => Capitalize(UpperDashToCamel(str));
|
|
48
|
+
const UpperDashToSnake = (str) => DashToSnake(UpperDashToDash(str));
|
|
49
|
+
const UpperDashToUpperSnake = (str) => Uppercase(UpperDashToSnake(str));
|
|
50
|
+
const UpperSnakeToCamel = (str) => SnakeToCamel(Lowercase(str));
|
|
51
|
+
const UpperSnakeToDash = (str) => str.replace(/(\_)/g, "-").toLowerCase();
|
|
52
|
+
const UpperSnakeToPascal = (str) => SnakeToPascal(Lowercase(str));
|
|
53
|
+
const UpperSnakeToSnake = (str) => Lowercase(str);
|
|
54
|
+
const UpperSnakeToUpperDash = (str) => Uppercase(UpperSnakeToDash(str));
|
|
91
55
|
function parse(input, type) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
56
|
+
return {
|
|
57
|
+
CamelToDash,
|
|
58
|
+
CamelToPascal,
|
|
59
|
+
CamelToSnake,
|
|
60
|
+
CamelToUpperDash,
|
|
61
|
+
CamelToUpperSnake,
|
|
62
|
+
DashToCamel,
|
|
63
|
+
DashToSnake,
|
|
64
|
+
DashToPascal,
|
|
65
|
+
DashToUpperSnake,
|
|
66
|
+
DashToUpperDash,
|
|
67
|
+
PascalToCamel,
|
|
68
|
+
PascalToSnake,
|
|
69
|
+
PascalToDash,
|
|
70
|
+
PascalToUpperSnake,
|
|
71
|
+
PascalToUpperDash,
|
|
72
|
+
SnakeToCamel,
|
|
73
|
+
SnakeToDash,
|
|
74
|
+
SnakeToPascal,
|
|
75
|
+
SnakeToUpperSnake,
|
|
76
|
+
SnakeToUpperDash,
|
|
77
|
+
UpperSnakeToCamel,
|
|
78
|
+
UpperSnakeToSnake,
|
|
79
|
+
UpperSnakeToDash,
|
|
80
|
+
UpperSnakeToPascal,
|
|
81
|
+
UpperSnakeToUpperDash,
|
|
82
|
+
UpperDashToCamel,
|
|
83
|
+
UpperDashToSnake,
|
|
84
|
+
UpperDashToDash,
|
|
85
|
+
UpperDashToPascal,
|
|
86
|
+
UpperDashToUpperSnake
|
|
87
|
+
}[type](input);
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/parser/objectParser.ts
|
|
127
91
|
function objectParser(input, type) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
92
|
+
const result = {};
|
|
93
|
+
for (const property of Object.keys(input)) {
|
|
94
|
+
const parsedKey = parse(property, type);
|
|
95
|
+
const value = input[property];
|
|
96
|
+
let parsedValue;
|
|
97
|
+
if (isArray(value)) parsedValue = arrayParser(value, type);
|
|
98
|
+
else if (isObject(value)) parsedValue = objectParser(value, type);
|
|
99
|
+
else parsedValue = value;
|
|
100
|
+
Object.defineProperty(result, parsedKey, {
|
|
101
|
+
value: parsedValue,
|
|
102
|
+
enumerable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
configurable: true
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/parser/arrayParser.ts
|
|
144
111
|
function arrayParser(input, type) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// src/parser/parser.ts
|
|
112
|
+
return input.map((item) => {
|
|
113
|
+
if (isArray(item)) return arrayParser(item, type);
|
|
114
|
+
if (isObject(item)) return objectParser(item, type);
|
|
115
|
+
return item;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/parser/parser.ts
|
|
155
120
|
function converter(input, type) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
121
|
+
let result;
|
|
122
|
+
if (isString(input)) result = parse(input, type);
|
|
123
|
+
if (isArray(input)) result = arrayParser(input, type);
|
|
124
|
+
if (isObject(input)) result = objectParser(input, type);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/camelCase/camelCase.ts
|
|
129
|
+
/**
|
|
130
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to dash-case.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* camelToDash('helloWorld'); // 'hello-world'
|
|
135
|
+
* camelToDash({ firstName: 'John' }); // { 'first-name': 'John' }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
167
138
|
function camelToDash(input) {
|
|
168
|
-
|
|
169
|
-
}
|
|
139
|
+
return converter(input, "CamelToDash");
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to snake_case.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* camelToSnake('helloWorld'); // 'hello_world'
|
|
147
|
+
* camelToSnake({ firstName: 'John' }); // { first_name: 'John' }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
170
150
|
function camelToSnake(input) {
|
|
171
|
-
|
|
172
|
-
}
|
|
151
|
+
return converter(input, "CamelToSnake");
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to PascalCase.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* camelToPascal('helloWorld'); // 'HelloWorld'
|
|
159
|
+
* camelToPascal({ firstName: 'John' }); // { FirstName: 'John' }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
173
162
|
function camelToPascal(input) {
|
|
174
|
-
|
|
175
|
-
}
|
|
163
|
+
return converter(input, "CamelToPascal");
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to UPPER_SNAKE_CASE.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* camelToUpperSnake('helloWorld'); // 'HELLO_WORLD'
|
|
171
|
+
* camelToUpperSnake({ firstName: 'John' }); // { FIRST_NAME: 'John' }
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
176
174
|
function camelToUpperSnake(input) {
|
|
177
|
-
|
|
178
|
-
}
|
|
175
|
+
return converter(input, "CamelToUpperSnake");
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Converts a string, or the keys of an object/array (deeply), from camelCase to UPPER-DASH-CASE.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* camelToUpperDash('helloWorld'); // 'HELLO-WORLD'
|
|
183
|
+
* camelToUpperDash({ firstName: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
179
186
|
function camelToUpperDash(input) {
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
// src/dashCase/dashCase.ts
|
|
187
|
+
return converter(input, "CamelToUpperDash");
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/dashCase/dashCase.ts
|
|
191
|
+
/**
|
|
192
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to snake_case.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* dashToSnake('hello-world'); // 'hello_world'
|
|
197
|
+
* dashToSnake({ 'first-name': 'John' }); // { first_name: 'John' }
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
194
200
|
function dashToSnake(input) {
|
|
195
|
-
|
|
196
|
-
}
|
|
201
|
+
return converter(input, "DashToSnake");
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to camelCase.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* dashToCamel('hello-world'); // 'helloWorld'
|
|
209
|
+
* dashToCamel({ 'first-name': 'John' }); // { firstName: 'John' }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
197
212
|
function dashToCamel(input) {
|
|
198
|
-
|
|
199
|
-
}
|
|
213
|
+
return converter(input, "DashToCamel");
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to PascalCase.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* dashToPascal('hello-world'); // 'HelloWorld'
|
|
221
|
+
* dashToPascal({ 'first-name': 'John' }); // { FirstName: 'John' }
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
200
224
|
function dashToPascal(input) {
|
|
201
|
-
|
|
202
|
-
}
|
|
225
|
+
return converter(input, "DashToPascal");
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to UPPER_SNAKE_CASE.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* dashToUpperSnake('hello-world'); // 'HELLO_WORLD'
|
|
233
|
+
* dashToUpperSnake({ 'first-name': 'John' }); // { FIRST_NAME: 'John' }
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
203
236
|
function dashToUpperSnake(input) {
|
|
204
|
-
|
|
205
|
-
}
|
|
237
|
+
return converter(input, "DashToUpperSnake");
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Converts a string, or the keys of an object/array (deeply), from dash-case to UPPER-DASH-CASE.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```ts
|
|
244
|
+
* dashToUpperDash('hello-world'); // 'HELLO-WORLD'
|
|
245
|
+
* dashToUpperDash({ 'first-name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
206
248
|
function dashToUpperDash(input) {
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
// src/pascalCase/pascalCase.ts
|
|
249
|
+
return converter(input, "DashToUpperDash");
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/pascalCase/pascalCase.ts
|
|
253
|
+
/**
|
|
254
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to camelCase.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* pascalToCamel('HelloWorld'); // 'helloWorld'
|
|
259
|
+
* pascalToCamel({ FirstName: 'John' }); // { firstName: 'John' }
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
221
262
|
function pascalToCamel(input) {
|
|
222
|
-
|
|
223
|
-
}
|
|
263
|
+
return converter(input, "PascalToCamel");
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to snake_case.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```ts
|
|
270
|
+
* pascalToSnake('HelloWorld'); // 'hello_world'
|
|
271
|
+
* pascalToSnake({ FirstName: 'John' }); // { first_name: 'John' }
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
224
274
|
function pascalToSnake(input) {
|
|
225
|
-
|
|
226
|
-
}
|
|
275
|
+
return converter(input, "PascalToSnake");
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to dash-case.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* pascalToDash('HelloWorld'); // 'hello-world'
|
|
283
|
+
* pascalToDash({ FirstName: 'John' }); // { 'first-name': 'John' }
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
227
286
|
function pascalToDash(input) {
|
|
228
|
-
|
|
229
|
-
}
|
|
287
|
+
return converter(input, "PascalToDash");
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to UPPER_SNAKE_CASE.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* pascalToUpperSnake('HelloWorld'); // 'HELLO_WORLD'
|
|
295
|
+
* pascalToUpperSnake({ FirstName: 'John' }); // { FIRST_NAME: 'John' }
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
230
298
|
function pascalToUpperSnake(input) {
|
|
231
|
-
|
|
232
|
-
}
|
|
299
|
+
return converter(input, "PascalToUpperSnake");
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Converts a string, or the keys of an object/array (deeply), from PascalCase to UPPER-DASH-CASE.
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```ts
|
|
306
|
+
* pascalToUpperDash('HelloWorld'); // 'HELLO-WORLD'
|
|
307
|
+
* pascalToUpperDash({ FirstName: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
233
310
|
function pascalToUpperDash(input) {
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
// src/snakeCase/snakeCase.ts
|
|
311
|
+
return converter(input, "PascalToUpperDash");
|
|
312
|
+
}
|
|
313
|
+
//#endregion
|
|
314
|
+
//#region src/snakeCase/snakeCase.ts
|
|
315
|
+
/**
|
|
316
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to camelCase.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```ts
|
|
320
|
+
* snakeToCamel('hello_world'); // 'helloWorld'
|
|
321
|
+
* snakeToCamel({ first_name: 'John' }); // { firstName: 'John' }
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
248
324
|
function snakeToCamel(input) {
|
|
249
|
-
|
|
250
|
-
}
|
|
325
|
+
return converter(input, "SnakeToCamel");
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to dash-case.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* snakeToDash('hello_world'); // 'hello-world'
|
|
333
|
+
* snakeToDash({ first_name: 'John' }); // { 'first-name': 'John' }
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
251
336
|
function snakeToDash(input) {
|
|
252
|
-
|
|
253
|
-
}
|
|
337
|
+
return converter(input, "SnakeToDash");
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to PascalCase.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```ts
|
|
344
|
+
* snakeToPascal('hello_world'); // 'HelloWorld'
|
|
345
|
+
* snakeToPascal({ first_name: 'John' }); // { FirstName: 'John' }
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
254
348
|
function snakeToPascal(input) {
|
|
255
|
-
|
|
256
|
-
}
|
|
349
|
+
return converter(input, "SnakeToPascal");
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to UPPER_SNAKE_CASE.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```ts
|
|
356
|
+
* snakeToUpperSnake('hello_world'); // 'HELLO_WORLD'
|
|
357
|
+
* snakeToUpperSnake({ first_name: 'John' }); // { FIRST_NAME: 'John' }
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
257
360
|
function snakeToUpperSnake(input) {
|
|
258
|
-
|
|
259
|
-
}
|
|
361
|
+
return converter(input, "SnakeToUpperSnake");
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Converts a string, or the keys of an object/array (deeply), from snake_case to UPPER-DASH-CASE.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* snakeToUpperDash('hello_world'); // 'HELLO-WORLD'
|
|
369
|
+
* snakeToUpperDash({ first_name: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
260
372
|
function snakeToUpperDash(input) {
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
// src/upperDashCase/upperDashCase.ts
|
|
373
|
+
return converter(input, "SnakeToUpperDash");
|
|
374
|
+
}
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/upperDashCase/upperDashCase.ts
|
|
377
|
+
/**
|
|
378
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to camelCase.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```ts
|
|
382
|
+
* upperDashToCamel('HELLO-WORLD'); // 'helloWorld'
|
|
383
|
+
* upperDashToCamel({ 'FIRST-NAME': 'John' }); // { firstName: 'John' }
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
275
386
|
function upperDashToCamel(input) {
|
|
276
|
-
|
|
277
|
-
}
|
|
387
|
+
return converter(input, "UpperDashToCamel");
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to snake_case.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* upperDashToSnake('HELLO-WORLD'); // 'hello_world'
|
|
395
|
+
* upperDashToSnake({ 'FIRST-NAME': 'John' }); // { first_name: 'John' }
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
278
398
|
function upperDashToSnake(input) {
|
|
279
|
-
|
|
280
|
-
}
|
|
399
|
+
return converter(input, "UpperDashToSnake");
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to dash-case.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```ts
|
|
406
|
+
* upperDashToDash('HELLO-WORLD'); // 'hello-world'
|
|
407
|
+
* upperDashToDash({ 'FIRST-NAME': 'John' }); // { 'first-name': 'John' }
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
281
410
|
function upperDashToDash(input) {
|
|
282
|
-
|
|
283
|
-
}
|
|
411
|
+
return converter(input, "UpperDashToDash");
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to PascalCase.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```ts
|
|
418
|
+
* upperDashToPascal('HELLO-WORLD'); // 'HelloWorld'
|
|
419
|
+
* upperDashToPascal({ 'FIRST-NAME': 'John' }); // { FirstName: 'John' }
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
284
422
|
function upperDashToPascal(input) {
|
|
285
|
-
|
|
286
|
-
}
|
|
423
|
+
return converter(input, "UpperDashToPascal");
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER-DASH-CASE to UPPER_SNAKE_CASE.
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```ts
|
|
430
|
+
* upperDashToUpperSnake('HELLO-WORLD'); // 'HELLO_WORLD'
|
|
431
|
+
* upperDashToUpperSnake({ 'FIRST-NAME': 'John' }); // { FIRST_NAME: 'John' }
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
287
434
|
function upperDashToUpperSnake(input) {
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
// src/upperSnakeCase/upperSnakeCase.ts
|
|
435
|
+
return converter(input, "UpperDashToUpperSnake");
|
|
436
|
+
}
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/upperSnakeCase/upperSnakeCase.ts
|
|
439
|
+
/**
|
|
440
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to camelCase.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* upperSnakeToCamel('HELLO_WORLD'); // 'helloWorld'
|
|
445
|
+
* upperSnakeToCamel({ FIRST_NAME: 'John' }); // { firstName: 'John' }
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
302
448
|
function upperSnakeToCamel(input) {
|
|
303
|
-
|
|
304
|
-
}
|
|
449
|
+
return converter(input, "UpperSnakeToCamel");
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to snake_case.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```ts
|
|
456
|
+
* upperSnakeToSnake('HELLO_WORLD'); // 'hello_world'
|
|
457
|
+
* upperSnakeToSnake({ FIRST_NAME: 'John' }); // { first_name: 'John' }
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
305
460
|
function upperSnakeToSnake(input) {
|
|
306
|
-
|
|
307
|
-
}
|
|
461
|
+
return converter(input, "UpperSnakeToSnake");
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to dash-case.
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```ts
|
|
468
|
+
* upperSnakeToDash('HELLO_WORLD'); // 'hello-world'
|
|
469
|
+
* upperSnakeToDash({ FIRST_NAME: 'John' }); // { 'first-name': 'John' }
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
308
472
|
function upperSnakeToDash(input) {
|
|
309
|
-
|
|
310
|
-
}
|
|
473
|
+
return converter(input, "UpperSnakeToDash");
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to PascalCase.
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```ts
|
|
480
|
+
* upperSnakeToPascal('HELLO_WORLD'); // 'HelloWorld'
|
|
481
|
+
* upperSnakeToPascal({ FIRST_NAME: 'John' }); // { FirstName: 'John' }
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
311
484
|
function upperSnakeToPascal(input) {
|
|
312
|
-
|
|
313
|
-
}
|
|
485
|
+
return converter(input, "UpperSnakeToPascal");
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Converts a string, or the keys of an object/array (deeply), from UPPER_SNAKE_CASE to UPPER-DASH-CASE.
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```ts
|
|
492
|
+
* upperSnakeToUpperDash('HELLO_WORLD'); // 'HELLO-WORLD'
|
|
493
|
+
* upperSnakeToUpperDash({ FIRST_NAME: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
314
496
|
function upperSnakeToUpperDash(input) {
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
var src_default = {
|
|
320
|
-
...camelCase_exports,
|
|
321
|
-
...dashCase_exports,
|
|
322
|
-
...pascalCase_exports,
|
|
323
|
-
...snakeCase_exports,
|
|
324
|
-
...upperDashCase_exports,
|
|
325
|
-
...upperSnakeCase_exports
|
|
326
|
-
};
|
|
497
|
+
return converter(input, "UpperSnakeToUpperDash");
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
500
|
+
export { camelToDash, camelToPascal, camelToSnake, camelToUpperDash, camelToUpperSnake, dashToCamel, dashToPascal, dashToSnake, dashToUpperDash, dashToUpperSnake, pascalToCamel, pascalToDash, pascalToSnake, pascalToUpperDash, pascalToUpperSnake, snakeToCamel, snakeToDash, snakeToPascal, snakeToUpperDash, snakeToUpperSnake, upperDashToCamel, upperDashToDash, upperDashToPascal, upperDashToSnake, upperDashToUpperSnake, upperSnakeToCamel, upperSnakeToDash, upperSnakeToPascal, upperSnakeToSnake, upperSnakeToUpperDash };
|