# swap-keys-in-object

> Swaps one key for another in an object

Latest version **2.0.5** (published 2016-08-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install swap-keys-in-object
pnpm add swap-keys-in-object
yarn add swap-keys-in-object
bun add swap-keys-in-object
```

## 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 | 2.0.5 |
| Published | 2016-08-24 |
| First published | 2016-08-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Zachary Smith |
| Maintainers | billyzac |

## Links

- npm: https://www.npmjs.com/package/swap-keys-in-object
- Repository: https://github.com/BillyZac/swap-keys-in-object
- Homepage: https://github.com/BillyZac/swap-keys-in-object#readme
- Issues: https://github.com/BillyZac/swap-keys-in-object/issues
- npm.io page: https://npm.io/package/swap-keys-in-object

## Recent versions

- 2.0.5 (latest) — 2016-08-24
- 2.0.3 — 2016-08-19
- 2.0.1 — 2016-08-19
- 1.0.1 — 2016-08-18
- 1.0.0 — 2016-08-18

## README

# Swap keys in an object!

## Usage
First install it:
```
npm install --save
```

Then use it:

```
const swapKeysInObject = require('swap-keys-in-object')
```

Say you have an object like this:

```
const oldFellow = {
    id: 'PloppyNop39',
    name: 'Crumbface',
    age: 137
}
```

But you want the keys to be preceded by underscores. Create a
map from your old keys onto your new keys:

```
const keyMap = {
    id: '_id',
    name: '_name',
    age: '_age'
}

```

Then you can swap out the old keys for new:

```
const newFellow = swapKeysInObject(keyMap, oldFellow)
```

The resulting `newFellow`:

```
{
    _id: 'PloppyNop39',
    _name: 'Crumbface',
    _age: 137
}
```

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