# lodash-humps

> Recursive camelCase of object keys and arrays of objects

Latest version **3.1.6** (published 2021-03-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install lodash-humps
pnpm add lodash-humps
yarn add lodash-humps
bun add lodash-humps
```

## 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 | 3.1.6 |
| Published | 2021-03-02 |
| First published | 2016-07-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 104.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 36 |
| Author | Kai Curry |
| Maintainers | kaicurry |
| Keywords | utils, camel, case, keys, underscore, converter, strings, lodash, objects |

## Links

- npm: https://www.npmjs.com/package/lodash-humps
- Repository: https://github.com/cape-io/lodash-humps
- Homepage: https://github.com/cape-io/lodash-humps#readme
- Issues: https://github.com/cape-io/lodash-humps/issues
- npm.io page: https://npm.io/package/lodash-humps

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21

## 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

- 3.1.6 (latest) — 2021-03-02
- 3.1.5 — 2019-07-11
- 3.1.4 — 2019-07-11
- 3.1.3 — 2019-07-11
- 3.1.2 — 2017-07-14
- 3.1.1 — 2017-06-20
- 3.1.0 — 2017-06-20
- 2.0.1 — 2017-01-04
- 2.0.0 — 2016-07-29
- 1.1.1 — 2016-07-20
- 1.1.0 — 2016-07-20
- 1.0.1 — 2016-07-20
- 1.0.0 — 2016-07-20

## README

# lodash-humps v3.1.2

Converting object keys to camelCase. Works on deeply nested objects/arrays. Handy for converting underscore keys to camelCase. Using lodash keeps the code small and light at around 10 lines.

## Install

```bash
$ npm i --save lodash-humps
```

## Usage

### Converting object keys

Remove any hyphens, underscores, whitespace characters, and uppercases the first character that follows. Returns a new object. See `_.camelCase()` https://lodash.com/docs#camelCase and https://en.wikipedia.org/wiki/CamelCase.

````javascript
import humps from 'lodash-humps'

const object = { attr_one: 'foo', attr_two: 'bar', attr_three: { attr_one: 'foo' } }
humps(object) // { attrOne: 'foo', attrTwo: 'bar', attrThree: { attrOne: 'foo' } }
````

Arrays of objects are also converted:

````javascript
const array = [{ attr_one: 'foo' }, { attr_one: 'bar' }]
humps(array) // [{ attrOne: 'foo' }, { attrOne: 'bar' }]
````

### Custom key converter

What if you want to convert it back?!? See test/createHumps.spec.js for an example. Open an issue if you want a proper export.

````javascript
import createHumps from 'humps/lib/createHumps'
import { snakeCase } from 'lodash'

const snakes = createHumps(snakeCase)
const object = { attrOne: 'foo', attrTwo: 'bar', attrThree: { attrOne: 'foo' } }
snakes(object) // { attr_one: 'foo', attr_two: 'bar', attr_three: { attr_one: 'foo' } }
````

## Version 3 Changes

**NOTE:** Version 3.x will only work with objects created by the Object constructor. You may need to do something like `const result = humps({ ...SomeOtherClass })` to get humps to process your stuff. Function properties are now kept and not converted to `{}`. Some might say this is a _bug_ and others might call it a _feature_. Full version bump so you can have your pick.

Internally switched from using `_.isObject` to `_.isPlainObject` before converting the keys and children objects.


## Prior Art

https://www.npmjs.com/package/humps

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