Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/NV/objectDiff.js
Compares JavaScript objects
https://github.com/NV/objectDiff.js
debugging-tool javascript
Last synced: about 1 month ago
JSON representation
Compares JavaScript objects
- Host: GitHub
- URL: https://github.com/NV/objectDiff.js
- Owner: NV
- License: mit
- Created: 2011-04-29T16:55:36.000Z (over 13 years ago)
- Default Branch: gh-pages
- Last Pushed: 2019-09-30T12:06:51.000Z (about 5 years ago)
- Last Synced: 2024-11-03T16:39:51.575Z (about 2 months ago)
- Topics: debugging-tool, javascript
- Language: JavaScript
- Homepage: http://nv.github.com/objectDiff.js/
- Size: 34.2 KB
- Stars: 261
- Watchers: 9
- Forks: 39
- Open Issues: 8
-
Metadata Files:
- Readme: README.mdown
- License: MIT-LICENSE.txt
Awesome Lists containing this project
README
# [objectDiff](http://nv.github.com/objectDiff.js/)
[objectdiff on npm](https://www.npmjs.com/package/objectdiff)
## objectDiff.diff(objectA, objectB)
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
}
}
}
}
}## objectDiff.diffOwnProperties(objectA, objectB)
Same as objectDiff.diff, but compares only objects' own properties
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}}}## 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/).