# map-merge

> apply a map function to merge a pair of deep data structures

Latest version **1.1.0** (published 2014-11-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install map-merge
pnpm add map-merge
yarn add map-merge
bun add map-merge
```

## 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.1.0 |
| Published | 2014-11-26 |
| First published | 2014-11-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Dominic Tarr |
| Maintainers | dominictarr |

## Links

- npm: https://www.npmjs.com/package/map-merge
- Repository: https://github.com/dominictarr/map-merge
- Issues: https://github.com/dominictarr/map-merge/issues
- npm.io page: https://npm.io/package/map-merge

## Recent versions

- 1.1.0 (latest) — 2014-11-26
- 1.0.0 — 2014-11-26

## README

# map-merge

deep merge two objects with a rule.
A new object is always returned.

I fear this may be a haskelly thing,
I suspect it might be an applicative functor.

almost the same module as [deep-merge](https://npm.im/deep-merge) but not quite.

## Example

``` js

var merge = require('map-merge')

merge(a, b, function (av, bv) {
  //use the value from b if a's corrisponding value is null/undefined
  return bv == null ? av : bv
  // btw, this is the default merge rule.
})

```

## Objects {}

objects are merged by their keys,
first all the keys in the left object are added,
then any keys in the right object which are not in the left.

This determins the order the keys appear in.

``` js
var merge = require('map-merge')

var a = {
  a: 'apple',
  b: 'banana',
  d: 'durian'
}
var b = {
  b: 'banana',
  c: 'cherry'
  e: 'elderberry'
}

var c = merge(a, b)
```

the order of the keys in `c` will depend on the order in a and b
``` js

{
  a: 'apple',
  b: 'banana',
  d: 'durian',
  c: 'cherry',
  e: 'elderberry'
}

```

## License

MIT

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