UNPKG

1.1 kBJavaScriptView Raw
1import camelCase from 'lodash.camelcase';
2import kebabCase from 'lodash.kebabcase';
3import snakeCase from 'lodash.snakecase';
4import upperFirst from 'lodash.upperfirst';
5import startCase from 'lodash.startcase';
6export default function toCase(input, target) {
7 switch (target) {
8 case 'camel-case':
9 return camelCase(input);
10 case 'kebab-case':
11 return kebabCase(input);
12 case 'snake-case':
13 return snakeCase(input);
14 case 'pascal-case':
15 return upperFirst(camelCase(input));
16 case 'start-case':
17 return startCase(input);
18 case 'upper-case':
19 case 'uppercase':
20 return input.toUpperCase();
21 case 'sentence-case':
22 case 'sentencecase':
23 return upperFirst(input);
24 case 'lower-case':
25 case 'lowercase':
26 case 'lowerCase': // Backwards compat config-angular v4
27 return input.toLowerCase();
28 default:
29 throw new TypeError(`to-case: Unknown target case "${target}"`);
30 }
31}
32//# sourceMappingURL=to-case.js.map
\No newline at end of file