diff-object
diffObject(oldObject, newObject)
Parameters
- oldObject
{Object}
:the object to diff from
- newObject
{Object}
:the object to diff to
Returns
{Array}
:
an array of object-patch objects
Find the differences between two objects, based on properties and values
The object-patch object format has the following keys:
- property: the property key on the new object
- type: the type of operation on this property: add, remove, or set
- value: the new value (if type is "add" or "set")
var diffObject = require("can-util/js/diff-object/diff-object");
console.log(diffObject({a: 1, b: 2}, {b: 3, c: 4})); // ->
[{property: "a", type: "remove"},
{property: "b", type: "set": value: 3},
{property: "c", type: "add", "value": 4}]