Utility for converting strings between camelCase, snake_case, kebab-case, etc.
Install the library via NPM:
npm install @fczbkk/convert-case --save
Then use in your project like this:
import convertCase from '@fczbkk/convert-case';
// convert between any combination of cases
var human_string = 'aaa bbb ccc';
var camel_string = convertCase(human_string, 'human', 'camel'); // aaaBbbCcc
var pascal_string = convertCase(camel_string, 'camel', 'pascal'); // AaaBbbCcc
var upper_string = convertCase(pascal_string, 'pascal', 'upper'); // AAA_BBB_CCC
var kebab_string = convertCase(upper_string, 'upper', 'kebab'); // aaa-bbb-ccc
Type of capitalization: human, camel, snake, kebab, upper or pascal.
Converts string from one type of capitalization to another.
Parameters
input
stringsource_case
CapitalizationTypetarget_case
CapitalizationType
Returns string
Breaks input into array containing metadata about each character.
Parameters
If you found any bugs, if you have feature requests or any questions, please, either file an issue at GitHub or send me an e-mail at riki@fczbkk.com. The best bug report is a pull request with failing test.
- All pull requests are welcome.
- Use
npm run dev
task for local development. It will start a watch task that will run tests against each code change. - Don't forget to add/update tests and documentation.
Thank you.
Convert case is published under the MIT license.