# update-diff

> Update object by mapping diff properties

Latest version **1.1.0** (published 2017-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install update-diff
pnpm add update-diff
yarn add update-diff
bun add update-diff
```

## 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 | 2017-10-17 |
| First published | 2017-10-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Dima Yv |
| Maintainers | dfcreative |
| Keywords | update-diff, map, map-obj, object-filter, map-object, update, diff, difference, patch, object, compare, change |

## Links

- npm: https://www.npmjs.com/package/update-diff
- Repository: https://github.com/dfcreative/update-diff
- Homepage: https://github.com/dfcreative/update-diff#readme
- Issues: https://github.com/dfcreative/update-diff/issues
- npm.io page: https://npm.io/package/update-diff

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

- 1.1.0 (latest) — 2017-10-17
- 1.0.3 — 2017-10-17
- 1.0.2 — 2017-10-05
- 1.0.1 — 2017-10-01
- 1.0.0 — 2017-10-01

## README

# update-diff [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges)

Update object by mapping differences in order. Comes handy for organizing state updating.

[![npm install update-diff](https://nodei.co/npm/update-diff.png?mini=true)](https://npmjs.org/package/update-diff/)

```js
let prop = require('update-diff')

let state = {propA: 0, propB: 1, propC: ['foo'], propD: 'bar'}

updateDiff(state, modifications, [
//initial mapping
{
	propA: value => value,
	propB: true,
	propC: Array.isArray
},
//second-pass mapping
{
	propX: (x, state) => state.propB + x
},
//third-pass mapping
{
	propA: (value, state) => state.propA ? 'a' : 'b'
}
])

// {propB: 1, propC: ['foo']}
```

## Related

* [obj-map-prop](https://github.com/dfcreative/obj-map-prop) − map object properties by a dict
* [map-obj](https://github.com/sindresorhus/map-obj) − map properties by single function
* [filter-obj](https://github.com/sindresorhus/filter-obj) − filter properties by single function


## Credits

© 2017 Dima Yv. MIT License

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