| | |
| | | # camelcase [](https://travis-ci.com/sindresorhus/camelcase) |
| | | # camelcase |
| | | |
| | | > Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar` |
| | | |
| | | Correctly handles Unicode strings. |
| | | |
| | | If you use this on untrusted user input, don't forget to limit the length to something reasonable. |
| | | |
| | | ## Install |
| | | |
| | |
| | | $ npm install camelcase |
| | | ``` |
| | | |
| | | *If you need to support Firefox, stay on version 5 as version 6 uses regex features not available in Firefox.* |
| | | *If you need to support Firefox < 78, stay on version 5 as version 6 uses regex features not available in Firefox < 78.* |
| | | |
| | | ## Usage |
| | | |
| | |
| | | camelCase('Foo-Bar'); |
| | | //=> 'fooBar' |
| | | |
| | | camelCase('розовый_пушистый_единороги'); |
| | | //=> 'розовыйПушистыйЕдинороги' |
| | | camelCase('розовый_пушистый_единорог'); |
| | | //=> 'розовыйПушистыйЕдинорог' |
| | | |
| | | camelCase('Foo-Bar', {pascalCase: true}); |
| | | //=> 'FooBar' |
| | |
| | | |
| | | ##### locale |
| | | |
| | | Type: `string | string[]`\ |
| | | Type: `false | string | string[]`\ |
| | | Default: The host environment’s current locale. |
| | | |
| | | The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used. |
| | |
| | | //=> 'loremİpsum' |
| | | ``` |
| | | |
| | | Setting `locale: false` ignores the platform locale and uses the [Unicode Default Case Conversion](https://unicode-org.github.io/icu/userguide/transforms/casemappings.html#simple-single-character-case-mapping) algorithm: |
| | | |
| | | ```js |
| | | const camelCase = require('camelcase'); |
| | | |
| | | // On a platform with 'tr-TR' |
| | | |
| | | camelCase('lorem-ipsum'); |
| | | //=> 'loremİpsum' |
| | | |
| | | camelCase('lorem-ipsum', {locale: false}); |
| | | //=> 'loremIpsum' |
| | | ``` |
| | | |
| | | ## camelcase for enterprise |
| | | |
| | | Available as part of the Tidelift Subscription. |