-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
47 lines (38 loc) · 1.26 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const toCamel = require('./lib/toCamel.js');
const toPascal = require('./lib/toPascal.js');
const toSnake = require('./lib/toSnake.js');
const toKebab = require('./lib/toKebab.js');
const pascal = 'HelloWorldWhatsUp';
const kebab = 'hello-world-whats-up';
const camel = 'helloWorldWhatsUp';
const snake = 'hello_world_whats_up';
console.log('\n------ Camel ------');
console.log(toCamel(pascal));
console.log(toCamel(kebab));
console.log(toCamel(camel));
console.log(toCamel(snake));
console.log('\n------ Pascal ------');
console.log(toPascal(pascal));
console.log(toPascal(kebab));
console.log(toPascal(camel));
console.log(toPascal(snake));
console.log('\n------ Snake ------');
console.log(toSnake(pascal));
console.log(toSnake(kebab));
console.log(toSnake(camel));
console.log(toSnake(snake));
console.log('\n------ Kebab ------');
console.log(toKebab(pascal));
console.log(toKebab(kebab));
console.log(toKebab(camel));
console.log(toKebab(snake));
console.log('\n------ Object keys ------');
const x = {
MyMulti : 'hello',
'and-dashed' : 'isWeird',
with_underscore: 'isPossible',
andAlsoCamels : 'are supported'
};
const res = Object.entries(x)
.map(([key, value]) => [ toKebab(key), value ]);
console.log(Object.fromEntries(res));