Skip to content

Commit 799707a

Browse files
author
Phillip Clark
committed
closes: issue #88, illustratiion
1 parent 809c1ee commit 799707a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

examples/issue-88.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var diff = require("../");
2+
3+
var before = {
4+
length: 3,
5+
data: [1, 2, 3]
6+
};
7+
8+
var after = {
9+
data: [4, 5, 1, 2, 3],
10+
count: 5
11+
};
12+
13+
var differences = diff(before, after);
14+
console.log(differences);
15+
16+
function applyChanges(target, changes) {
17+
return changes.reduce(
18+
(acc, change) => {
19+
diff.applyChange(acc, true, change);
20+
return acc;
21+
},
22+
target
23+
);
24+
}
25+
26+
console.log(applyChanges(before, differences));

0 commit comments

Comments
 (0)