1 | function utils(){
|
2 | var toCapitalCase = function(str){
|
3 | return str.charAt(0).toUpperCase() + str.slice(1);
|
4 | }
|
5 |
|
6 | var snakeToCamelCase = function (type) {
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | let formattedType = type;
|
12 | while(formattedType.indexOf('-') !== -1){
|
13 | let idx = formattedType.indexOf('-');
|
14 | let splitString = formattedType.split('');
|
15 | splitString.splice(idx, 1);
|
16 | splitString[idx] = splitString[idx].toUpperCase();
|
17 | formattedType = splitString.join('');
|
18 | }
|
19 |
|
20 | return formattedType;
|
21 | }
|
22 |
|
23 | return {
|
24 | toCapitalCase,
|
25 | snakeToCamelCase
|
26 | }
|
27 | }
|
28 |
|
29 | module.exports = utils(); |
\ | No newline at end of file |