# @sa0001/deep-diff

> [NPM][https://www.npmjs.com/package/@sa0001/deep-diff]

Latest version **0.0.11** (published 2021-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sa0001/deep-diff
pnpm add @sa0001/deep-diff
yarn add @sa0001/deep-diff
bun add @sa0001/deep-diff
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.11 |
| Published | 2021-01-23 |
| First published | 2017-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 23.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | sa0001 |
| Maintainers | sa0001 |

## Links

- npm: https://www.npmjs.com/package/@sa0001/deep-diff
- Repository: https://github.com/sa-0001/deep-diff-js
- Homepage: https://github.com/sa-0001/deep-diff-js#readme
- Issues: https://github.com/sa-0001/deep-diff-js/issues
- npm.io page: https://npm.io/package/@sa0001/deep-diff

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [@sa0001/type-of](https://npm.io/package/@sa0001/type-of.md) ^0.0.7
- [@sa0001/pretty-print](https://npm.io/package/@sa0001/pretty-print.md) ^0.0.9

## Recent versions

- 0.0.11 (latest) — 2021-01-23
- 0.0.10 — 2020-09-15
- 0.0.9 — 2020-09-15
- 0.0.8 — 2020-08-26
- 0.0.7 — 2019-01-24
- 0.0.6 — 2019-01-24
- 0.0.4 — 2018-05-18
- 0.0.3 — 2018-05-18
- 0.0.2 — 2018-05-15
- 0.0.1 — 2017-12-13

## README

# @sa0001/deep-diff

[NPM][https://www.npmjs.com/package/@sa0001/deep-diff]

This module makes a reliable, readable, deep diff between any two objects or arrays.

There are options to keep only the fields which are different on the right side, or to display both the left and right values for any field which is different.

## Install

```bash
npm install @sa0001/deep-diff
```

## Usage

```javascript
const deepDiff = require('@sa0001/deep-diff')

let left = {
	fieldA: 'a'
	fieldB: 'b'
	fieldC: {
		fieldD: 'd'
	}
}
let right = {
	fieldA: 'a'
	fieldB: 'B'
	fieldC: {
		fieldD: 'D'
	}
	fieldE: 'e'
}

// by default, the result is a comparison of all values
//  which are different in `left` and `right`
deepDiff(left, right)
/*
	{
		fieldB: {
			l: 'b',
			r: 'B'
		},
		fieldC: {
			fieldD: {
				l: 'd',
				r: 'D'
			}
		},
		fieldE: {
			l: undefined,
			r: 'e'
		}
	}
*/

// with option `keepRight`, the result will contain
//  all values in `right` which are different from `left`
deepDiff(left, right, { keepRight: true })
/*
	{
		fieldB: 'B',
		fieldC: {
			fieldD: 'D'
		}
	}
*/

// with option `shallow`, the diff will be at top-level
//  (but the comparison is still deep)
deepDiff(left, right, { shallow: true })
/*
	{
		fieldB: {
			l: 'b',
			r: 'B'
		},
		fieldC: {
			l: {
				fieldD: 'd'
			},
			r: {
				fieldD: 'D'
			}
		}
		fieldE: {
			l: undefined,
			r: 'e'
		}
	}
*/
```

## License

[MIT](http://vjpr.mit-license.org)

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