# caesar-caser

> Simple but powerful utility for case style detection and converting

Latest version **1.0.0-rc.2** (published 2019-11-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install caesar-caser
pnpm add caesar-caser
yarn add caesar-caser
bun add caesar-caser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-rc.2 |
| Published | 2019-11-12 |
| First published | 2019-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Adlite |
| Maintainers | adlite |
| Keywords | code-conventions, case-system |

## Links

- npm: https://www.npmjs.com/package/caesar-caser
- Repository: https://github.com/adlite/caesar-caser
- Homepage: https://github.com/adlite/caesar-caser#readme
- Issues: https://github.com/adlite/caesar-caser/issues
- npm.io page: https://npm.io/package/caesar-caser

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.0-rc.2 (latest) — 2019-11-12
- 1.0.0-rc.1 — 2019-10-22

## README

# Caesar Caser ⚔
Simple but powerful utility for case style detection and converting.

## Install
```shell script
npm install caesar-caser --save
```
or if you use Yarn
```shell script
yarn add caesar-caser
```

## Usage
```javascript
const caser = require('caesar-caser');

// Converts string from one specific case to another
caser('fooBarBaz').convert('camel', 'constant'); // => FOO_BAR_BAZ

// Converts string to specific case with autodetection
caser('fooBarBaz').convertTo('pascal'); // => FooBarBaz
caser('FOO_BAR_BAZ').convertTo('kebab'); // => foo-bar-baz
caser('foo_bar_baz').convertTo('sentence'); // => Foo bar baz

// Detects case and return its name
caser('fooBarBaz').detect(); // => camel
caser('FOO_BAR_BAZ').detect(); // => constant
caser('Foo Bar Baz').detect(); // => cap-sentence

// Also you can specify priority case name if passed string is unobvious
// For example string 'foo' can be in camel, kebab, snake and other cases
caser('foo').detect(); // => camel
caser('foo').detect('snake'); // => snake
// But if caser detects exact case this argument will be omitted
caser('fooBarBaz').detect('snake'); // => camel

// Normalizes given string by splitting it to array of lowercased chunks
caser('fooBarBaz').normalize('camel'); // => ['foo', 'bar', 'baz']
```

## Available case rules
| Name             | Example     | Description                                              |
|------------------|-------------|----------------------------------------------------------|
| 'camel'          | fooBarBaz   | Camel case                                               |
| 'pascal'         | FooBarBaz   | Pascal case (sometimes called upper camel or bumpy case) |
| 'kebab'          | foo-bar-baz | Kebab case (also known as dash case)                     |
| 'train'          | FOO-BAR-BAZ | Train case                                               |
| 'snake'          | foo_bar_baz | Snake case (may also be called pothole case)             |
| 'constant'       | FOO_BAR_BAZ | Constant case (also known as screaming snake case)       |
| 'dot'            | foo.bar.baz | Dot case                                                 |
| 'upper-dot'      | FOO.BAR.BAZ | Upper dot case                                           |
| 'sentence'       | Foo bar baz | Sentence case                                            |
| 'cap-sentence'   | Foo Bar Baz | Like the sentence case but every word is capitalized     |
| 'upper-sentence' | FOO BAR BAZ | Like the sentence case but every word is in uppercase    |
| 'lower-sentence' | foo bar baz | Like the sentence case but every word is in lowercase    |

## Maintainers
[Igor Sebelev](https://github.com/adlite)

## License
MIT

---
_Source: https://npm.io/package/caesar-caser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
