1 |
3a515b92
|
cagy
|
# decamelize [![Build Status](https://travis-ci.org/sindresorhus/decamelize.svg?branch=master)](https://travis-ci.org/sindresorhus/decamelize)
|
2 |
|
|
|
3 |
|
|
> Convert a camelized string into a lowercased one with a custom separator<br>
|
4 |
|
|
> Example: `unicornRainbow` → `unicorn_rainbow`
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
## Install
|
8 |
|
|
|
9 |
|
|
```
|
10 |
|
|
$ npm install --save decamelize
|
11 |
|
|
```
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
## Usage
|
15 |
|
|
|
16 |
|
|
```js
|
17 |
|
|
const decamelize = require('decamelize');
|
18 |
|
|
|
19 |
|
|
decamelize('unicornRainbow');
|
20 |
|
|
//=> 'unicorn_rainbow'
|
21 |
|
|
|
22 |
|
|
decamelize('unicornRainbow', '-');
|
23 |
|
|
//=> 'unicorn-rainbow'
|
24 |
|
|
```
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
## API
|
28 |
|
|
|
29 |
|
|
### decamelize(input, [separator])
|
30 |
|
|
|
31 |
|
|
#### input
|
32 |
|
|
|
33 |
|
|
Type: `string`
|
34 |
|
|
|
35 |
|
|
#### separator
|
36 |
|
|
|
37 |
|
|
Type: `string`<br>
|
38 |
|
|
Default: `_`
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
## Related
|
42 |
|
|
|
43 |
|
|
See [`camelcase`](https://github.com/sindresorhus/camelcase) for the inverse.
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
## License
|
47 |
|
|
|
48 |
|
|
MIT © [Sindre Sorhus](https://sindresorhus.com)
|