javascript - How to diff two immutable objects -
is there way diff objects in immutable?
example:
let = immutable.fromjs({ a: 10 }); let b = immutable.fromjs({ b: 10 }); let d = immutable.diff(a, b); // { a: 10 } console.log(d.tojs());
this useful when testing see how objects differ.
it doesn't have show what's added/removed explicitly. want see properties a
differs b
can make them equal again.
for example this:
console.log(a.tojs()); console.log(b.tojs());
and check logs see differs b.
in other thought might show both added
, removed
properties in same output. main point see not equal.
so be:
// { a: 10, b: 10 } console.log(d.tojs());
or maybe:
// { added: { a: 10 }, removed: { b: 10 } } // console.log(d.tojs());
Comments
Post a Comment