# @mmckelvy/map-object

> Map over an object calling a function on each key / value pair.

Latest version **1.0.3** (published 2020-01-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mmckelvy/map-object
pnpm add @mmckelvy/map-object
yarn add @mmckelvy/map-object
bun add @mmckelvy/map-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 | 1.0.3 |
| Published | 2020-01-02 |
| First published | 2019-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mark McKelvy |
| Maintainers | mmckelvy |
| Keywords | map-object |

## Links

- npm: https://www.npmjs.com/package/@mmckelvy/map-object
- Repository: https://github.com/mmckelvy/map-object
- Homepage: https://github.com/mmckelvy/map-object#readme
- Issues: https://github.com/mmckelvy/map-object/issues
- npm.io page: https://npm.io/package/@mmckelvy/map-object

## Recent versions

- 1.0.3 (latest) — 2020-01-02
- 1.0.2 — 2019-12-20
- 1.0.1 — 2019-08-17
- 1.0.0 — 2019-08-16

## README

# map-object
Map over an object calling a function on each key / val pair.

## Installation
```bash
npm install @mmckelvy/map-object
```

## Usage
```javascript
const mapObject = require('@mmckelvy/map-object');

const obj = {
  apple: 'fruit',
  green: 'color'
};

const mapped = mapObject(obj, (key, val) => {
  return [val, key];
});

/* ->
{
  fruit: 'apple',
  color: 'green'
}
*/
```

## API
### `mapObject(obj, fn, options)`

#### obj `object`

The source object.


#### fn `function`

A function to call on each key / val pair.

function signature is as follows:
#### `fn(key, value, source?)`

##### key `string`

##### value `any`

##### source `object`

The source object.

##### return
An array with `[targetKey, targetValue]` elements.


#### options `object`

##### options.recursive `boolean`

Map over nested objects.


#### return
`object` The mapped object.

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