Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow
npm install decamelize> Convert a camelized string into a lowercased one with a custom separator\
> Example: unicornRainbow → unicorn_rainbow
If you use this on untrusted user input, don't forget to limit the length to something reasonable.
``sh`
npm install decamelize
If you need Safari support, stay on version 3 until they implement regex lookbehinds.
`js
import decamelize from 'decamelize';
decamelize('unicornRainbow');
//=> 'unicorn_rainbow'
decamelize('unicornRainbow', {separator: '-'});
//=> 'unicorn-rainbow'
decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
//=> 'test_GUI_label'
decamelize('testGUILabel', {preserveConsecutiveUppercase: false});
//=> 'test_gui_label'
`
#### input
Type: string
#### options
Type: object
##### separator
Type: string\'_'
Default:
The character or string used to separate words.
`js
import decamelize from 'decamelize';
decamelize('unicornRainbow');
//=> 'unicorn_rainbow'
decamelize('unicornRainbow', {separator: '-'});
//=> 'unicorn-rainbow'
`
##### preserveConsecutiveUppercase
Type: boolean\false
Default:
Preserve sequences of uppercase characters.
`js
import decamelize from 'decamelize';
decamelize('testGUILabel');
//=> 'test_gui_label'
decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
//=> 'test_GUI_label'
``
- camelcase - The inverse of this package
- decamelize-keys - Convert object keys from camel case