2016-10-10 03:43:44 +02:00
|
|
|
# camelcase [![Build Status](https://travis-ci.org/sindresorhus/camelcase.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase)
|
|
|
|
|
|
|
|
> Convert a dash/dot/underscore/space separated string to camelCase: `foo-bar` → `fooBar`
|
|
|
|
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
2017-04-20 03:09:25 +02:00
|
|
|
```
|
2016-10-10 03:43:44 +02:00
|
|
|
$ npm install --save camelcase
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```js
|
2017-04-20 03:09:25 +02:00
|
|
|
const camelCase = require('camelcase');
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('foo-bar');
|
2017-04-20 03:09:25 +02:00
|
|
|
//=> 'fooBar'
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('foo_bar');
|
2017-04-20 03:09:25 +02:00
|
|
|
//=> 'fooBar'
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('Foo-Bar');
|
2017-04-20 03:09:25 +02:00
|
|
|
//=> 'fooBar'
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('--foo.bar');
|
2017-04-20 03:09:25 +02:00
|
|
|
//=> 'fooBar'
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('__foo__bar__');
|
2017-04-20 03:09:25 +02:00
|
|
|
//=> 'fooBar'
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('foo bar');
|
2017-04-20 03:09:25 +02:00
|
|
|
//=> 'fooBar'
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
console.log(process.argv[3]);
|
2017-04-20 03:09:25 +02:00
|
|
|
//=> '--foo-bar'
|
2016-10-10 03:43:44 +02:00
|
|
|
camelCase(process.argv[3]);
|
2017-04-20 03:09:25 +02:00
|
|
|
//=> 'fooBar'
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('foo', 'bar');
|
2017-04-20 03:09:25 +02:00
|
|
|
//=> 'fooBar'
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('__foo__', '--bar');
|
2017-04-20 03:09:25 +02:00
|
|
|
//=> 'fooBar'
|
2016-10-10 03:43:44 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Related
|
|
|
|
|
2017-04-20 03:09:25 +02:00
|
|
|
- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
|
|
|
|
- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
MIT © [Sindre Sorhus](http://sindresorhus.com)
|