$ gnpm 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.
npm install decamelize
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'
Type: string
Type: object
Type: string
Default: '_'
Character or string inserted to separate words in string
.
import decamelize from 'decamelize';
decamelize('unicornRainbow');
//=> 'unicorn_rainbow'
decamelize('unicornRainbow', {separator: '-'});
//=> 'unicorn-rainbow'
Type: boolean
Default: false
Preserve sequences of uppercase characters.
import decamelize from 'decamelize';
decamelize('testGUILabel');
//=> 'test_gui_label'
decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
//=> 'test_GUI_label'
See camelcase
for the inverse.
Copyright 2013 - present © cnpmjs.org | Home |