# Variable Name Conversion

[![npm](https://img.shields.io/npm/v/variable-name-conversion?logo=npm&logoColor=%23CB3837&label=npm&labelColor=white&color=%23CB3837)](https://www.npmjs.org/package/variable-name-conversion)
[![GitHub](https://img.shields.io/npm/v/variable-name-conversion?logo=github&label=GitHub&color=%23181717)](https://github.com/otomad/variable-name-conversion.js)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)][license-url]

[license-url]: https://opensource.org/licenses/MIT

To easily convert a variable name to camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, etc.

## Installation

```bash
# npm
npm install variable-name-conversion

# yarn
yarn add variable-name-conversion

# pnpm
pnpm add variable-name-conversion
```

## Usage
```javascript
import VariableName from "variable-name-conversion";

new VariableName("hello_world").camel; //=> "helloWorld"
new VariableName("fooBarBaz").kebab; //=> "foo-bar-baz"
```

## Cases

Case | Example | Notes
--- | --- | ---
`camel` | `camelCase`
`pascal` | `PascalCase`
`kebab` | `kebab-case`
`snake` | `snake_case`
`const` | `CONSTANT_CASE`
`train` | `Train-Case`
`cobol` | `COBOL-CASE`
`pascalSnake` | `Pascal_Snake_Case`
`camelSnake` | `camel_Snake_Case`
`dot` | `dot.case`
`path` | `path/case`
`pathAlt` | `path\alt\case`
`lower` | `lowercase` | With no separators.
`upper` | `UPPERCASE` | With no separators.
`words` | `word case` | Separated by spaces, all in lowercase.
`sentence` | `Sentence case` | Separated by spaces, with only the first letter of the sentence capitalized.
`title` | `Title Case` | Separated by spaces, with all first letters of words capitalized.
`cssVar` | `--css-custom-property-name-form` | `kebab-case` with two dashes as the prefix.
`cssProp` | `css-property-name-form`<br />`-webkit-css-property-name-form` | Just like kebab-case, but if the first word is in "webkit", "moz", "ms", "o", it will use one dash as the prefix.

## Options

### keepCase

Should it maintain case sensitivity when converting to kebab-case, snake_case, etc.?

**Default:** false

Example:

```javascript
new VariableName("XMLHttpRequest").snake; //=> "xml_http_request"
new VariableName("XMLHttpRequest", true).snake; //=> "XML_Http_Request"

new VariableName("XMLHttpRequest").camel; //=> "xmlHttpRequest"
new VariableName("XMLHttpRequest", true).camel; //=> "XMLHttpRequest"
```

## License

variable-name-conversion is available under the [MIT License][license-url]. See the LICENSE file for more info.
