# key-mapper

> Deeply map object keys

Latest version **1.0.1** (published 2017-04-21) · MIT license · 0 weekly downloads

## Install

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

## 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.1 |
| Published | 2017-04-21 |
| First published | 2017-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kevin Lanni |
| Maintainers | therealklanni |
| Keywords | object, keys, mapper |

## Links

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

## Dependencies (1)

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

## Recent versions

- 1.0.1 (latest) — 2017-04-21
- 1.0.0 — 2017-04-21

## README

[![Travis](https://img.shields.io/travis/therealklanni/key-mapper.svg)](https://travis-ci.org/therealklanni/key-mapper)
[![npm](https://img.shields.io/npm/v/key-mapper.svg)](https://www.npmjs.com/package/key-mapper)
[![prettier](https://img.shields.io/badge/style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Beerpay](https://img.shields.io/beerpay/hashdog/scrapfy-chrome-extension.svg)](https://beerpay.io/therealklanni/key-mapper)


# key-mapper

> Tiny utility for deeply mapping object keys

Map object keys (properties) to transform an object of any shape and depth<sup>*</sup>.

<sub>* Obviously, there's such a thing as a call stack. If you're working with very large
objects, you should consider mapping small subsets of the object instead.</sub>

## Install

```
yarn add key-mapper --save
```

```
npm install key-mapper --save
```

## Usage

Any object supplied will be deeply mapped, including arrays of objects. Any non-object, non-array
contents will be skipped over. This includes any combination (to any depth) of array of objects and objects with arrays, and so on.

```js
km(sourceObject, _.camelCase) // => convert keys to camel case
```

If you want to exclude certain properties from the mapping, add an optional prefilter function.
For example, omit all properties named "options". Note that this means the resulting object will
_not_ have any properties named "options", not that it skips them.

```js
km(sourceObject, _.camelCase, omitOptions)
```

This is useful for working with large objects that could cause key-mapper to hit the call stack
limit. You could create multiple objects, one with the keys mapped, another with just the keys you
wanted to exclude, then merge them back together.

```
const mapped = km(sourceObject, _.camelCase, omitOptions)

// here, pickOptions does the opposite of omitOptions
const filtered = km(sourceObject, _.identity, pickOptions)

const finalForm = _.merge(filtered, mapped)
```

Notice how I used `_.identity` to leave the keys as-is so I could still deeply pick "options". #protip

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