# objectdiff

> Compares JavaScript objects

Latest version **1.1.0** (published 2013-06-20) · 0 weekly downloads

## Install

```sh
npm install objectdiff
pnpm add objectdiff
yarn add objectdiff
bun add objectdiff
```

## 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 | 2013-06-20 |
| First published | 2011-11-02 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.2.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 257 |
| Author | Nikita Vasilyev |
| Maintainers | nv |
| Keywords | diff |

## Links

- npm: https://www.npmjs.com/package/objectdiff
- Repository: https://github.com/NV/objectDiff.js
- Issues: https://github.com/NV/objectDiff.js/issues
- npm.io page: https://npm.io/package/objectdiff

## Recent versions

- 1.1.0 (latest) — 2013-06-20
- 1.0.0 — 2011-11-02

## README

#[objectDiff](http://nv.github.com/objectDiff.js/)

[objectdiff on npm](http://search.npmjs.org/#/objectdiff)


## objectDiff.diff(objectA, objectB)

<pre>
objectDiff.diff({x: 1}, {x: 2})
-> {
  changed: "object change",
  value: {
    x: {
      changed: "primitive change",
      removed: 1,
      added: 2
    }
  }
}

objectDiff.diff({z: {x: 1}}, {z: {y: 2}})
-> {
  changed: "object change",
  value: {
    z: {
      changed: "object change",
      value: {
        x: {
          changed: "removed",
          value: 1
        },
        y: {
          changed: "added",
          value: 2
        }
      }
    }
  }
}
</pre>


## objectDiff.diffOwnProperties(objectA, objectB)

Same as objectDiff.diff, but compares only objects' own properties

<pre>
function A(){}
A.prototype.x = 1
objectDiff.diff({x: 1}, new A)
-> {changed: "equal", value: {x: 1}}

objectDiff.diffOwnProperties({x: 1}, new A)
-> {changed: "object change", value: {x: {changed: "removed", value: 1}}}
</pre>

## objectDiff.convertToXMLString(diffObject)

Used on [the demo page](http://nv.github.com/objectDiff.js/).

## Jasmine integration

objectDiff provides `toEqualProperties` and `toEqualOwnProperties` matchers for [Jasmine](http://pivotal.github.com/jasmine/).
See [example spec](http://nv.github.com/objectDiff.js/spec/).

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