# case-key

> Convert object keys from camelCase to snake_case or vice versa

Latest version **0.0.1-alpha.2** (published 2020-07-31) · WTFPL license · 0 weekly downloads

## Install

```sh
npm install case-key
pnpm add case-key
yarn add case-key
bun add case-key
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1-alpha.2 |
| Published | 2020-07-31 |
| First published | 2020-07-25 |
| Weekly downloads | 0 |
| License | WTFPL |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ouyang-chao |
| Maintainers | oyang |

## Links

- npm: https://www.npmjs.com/package/case-key
- Repository: https://github.com/oychao/case-key
- Homepage: https://github.com/oychao/case-key#readme
- Issues: https://github.com/oychao/case-key/issues
- npm.io page: https://npm.io/package/case-key

## Dependencies (2)

- [camelcase](https://npm.io/package/camelcase.md) ^6.0.0
- [to-snake-case](https://npm.io/package/to-snake-case.md) ^1.0.0

## Recent versions

- 0.0.1-alpha.2 (latest) — 2020-07-31
- 0.0.1-alpha.1 — 2020-07-26
- 0.0.1-alpha.0 — 2020-07-25

## README

# case-key

Convert object keys from camelCase to snake_case or vice versa

This lib is originated from [sindresorhus/camelcase-keys](https://github.com/sindresorhus/camelcase-keys) and [bendrucker/snakecase-keys](https://github.com/bendrucker/snakecase-keys), for `exclude` option in camelcase-keys and snakecase-keys does not stop recursion in nested objects.

## Usage

```typescript
interface KeyCaseOptions {
  deep?: boolean; // default true
  exclude?: Array<RegExp>; // default []
  strictKey?: boolean; // default true
}

camelcase(target: object, option: KeyCaseOptions);

snakecase(target: object, option: KeyCaseOptions);
```

## Demo Code

```typescript
import { camelcase, snakecase } from 'case-key';

camelcase({
  hello_world: {
    camel_case: {
      some_key: 123
    }
  }
}, {
  exclude: [/case/]
});

/*
{
  helloWorld: {
    camel_case: {
      some_key: 123
    }
  }
}
*/

camelcase({ 'hello.world': 'case' }, { strictKey: true }); // output hello.world

camelcase({ 'hello.world': 'case' }, { strictKey: false }); // output helloWorld
```

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