Skip to content

Commit bc14ad0

Browse files
committed
Add basic readme
1 parent 13d7789 commit bc14ad0

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

README.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Deep Object Diff
2+
3+
A small library that will deep diff two JavaScript Objects, including nested structures of arrays and objects, and return the difference.
4+
5+
### Useage:
6+
```js
7+
const lhs = {
8+
foo: {
9+
bar: {
10+
a: [1, 2],
11+
b: 2,
12+
c: ['x', 'y'],
13+
e: 100 // deleted
14+
}
15+
},
16+
buzz: 'world'
17+
};
18+
19+
const rhs = {
20+
foo: {
21+
bar: {
22+
a: [1], // updated (value deleted)
23+
b: 2, // unchanged
24+
c: ['x', 'y', 'z'], // updated (value added)
25+
d: 'Hello, world!' // added
26+
}
27+
},
28+
buzz: 'fizz' // updated
29+
};
30+
31+
console.log(diff(lhs, rhs));
32+
33+
/* logs:
34+
{
35+
foo: {
36+
bar: {
37+
a: {
38+
'1': undefined
39+
},
40+
c: {
41+
'2': 'z'
42+
},
43+
d: 'Hello, world!',
44+
e: undefined
45+
}
46+
},
47+
buzz: 'fizz'
48+
}
49+
*/
50+
```

0 commit comments

Comments
 (0)