UNPKG

1.04 kBMarkdownView Raw
1# camelcase [![Build Status](https://travis-ci.org/sindresorhus/camelcase.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase)
2
3> Convert a dash/dot/underscore/space separated string to camelCase: `foo-bar` → `fooBar`
4
5
6## Install
7
8```
9$ npm install --save camelcase
10```
11
12
13## Usage
14
15```js
16const camelCase = require('camelcase');
17
18camelCase('foo-bar');
19//=> 'fooBar'
20
21camelCase('foo_bar');
22//=> 'fooBar'
23
24camelCase('Foo-Bar');
25//=> 'fooBar'
26
27camelCase('--foo.bar');
28//=> 'fooBar'
29
30camelCase('__foo__bar__');
31//=> 'fooBar'
32
33camelCase('foo bar');
34//=> 'fooBar'
35
36console.log(process.argv[3]);
37//=> '--foo-bar'
38camelCase(process.argv[3]);
39//=> 'fooBar'
40
41camelCase('foo', 'bar');
42//=> 'fooBar'
43
44camelCase('__foo__', '--bar');
45//=> 'fooBar'
46```
47
48
49## Related
50
51- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
52- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
53
54
55## License
56
57MIT © [Sindre Sorhus](http://sindresorhus.com)