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
|
|
|
|
|
2016-11-13 21:53:45 +01:00
|
|
|
```sh
|
2016-10-10 03:43:44 +02:00
|
|
|
$ npm install --save camelcase
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```js
|
2016-11-13 21:53:45 +01:00
|
|
|
var camelCase = require('camelcase');
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('foo-bar');
|
2016-11-13 21:53:45 +01:00
|
|
|
//=> fooBar
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('foo_bar');
|
2016-11-13 21:53:45 +01:00
|
|
|
//=> fooBar
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('Foo-Bar');
|
2016-11-13 21:53:45 +01:00
|
|
|
//=> fooBar
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('--foo.bar');
|
2016-11-13 21:53:45 +01:00
|
|
|
//=> fooBar
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('__foo__bar__');
|
2016-11-13 21:53:45 +01:00
|
|
|
//=> fooBar
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('foo bar');
|
2016-11-13 21:53:45 +01:00
|
|
|
//=> fooBar
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
console.log(process.argv[3]);
|
2016-11-13 21:53:45 +01:00
|
|
|
//=> --foo-bar
|
2016-10-10 03:43:44 +02:00
|
|
|
camelCase(process.argv[3]);
|
2016-11-13 21:53:45 +01:00
|
|
|
//=> fooBar
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('foo', 'bar');
|
2016-11-13 21:53:45 +01:00
|
|
|
//=> fooBar
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
camelCase('__foo__', '--bar');
|
2016-11-13 21:53:45 +01:00
|
|
|
//=> fooBar
|
2016-10-10 03:43:44 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Related
|
|
|
|
|
2016-11-13 21:53:45 +01:00
|
|
|
See [`decamelize`](https://github.com/sindresorhus/decamelize) for the inverse.
|
2016-10-10 03:43:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
MIT © [Sindre Sorhus](http://sindresorhus.com)
|