minor tweaking and cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-08-29 01:12:57 +03:00
parent b01c82036c
commit 33b6e0d6d8
2 changed files with 14 additions and 13 deletions

View File

@ -122,7 +122,7 @@ diff.patch(Bill2)
```
Since we applied *all* the changes to `Bill2`, now he looks just like `Ted`:
Since we applied *all* the changes to `Bill2`, now he is just another `Ted` (or rather `Ted`'s copy):
```javascript
//JSON.stringify(Bill2, null, '\t')

25
diff.js
View File

@ -955,6 +955,8 @@ module.Types = {
},
// User API...
// Reverse diff...
//
reverse: function(diff){
@ -1092,9 +1094,6 @@ module.Types = {
return this.flatten(diff).concat(this.flatten(other))
},
// User API...
// Build a diff between A and B...
//
// NOTE: this will include direct links to items.
@ -1253,6 +1252,16 @@ module.Types = {
})
.pop())
},
// Call the post-patch method of the handlers...
//
postPatch: function(res){
var that = this
return [...this.types]
.filter(function(e){
return !!e.postPatch })
.reduce(function(r, e){
return e.postPatch.call(that, r) }, res) },
// XXX need to support different path element types...
// ...in addition to Object and Array items, support Map, Set, ...
@ -1329,15 +1338,7 @@ module.Types = {
})
.pop())
},
// Call the post-patch method of the handlers...
//
postPatch: function(res){
var that = this
return [...this.types]
.filter(function(e){
return !!e.postPatch })
.reduce(function(r, e){
return e.postPatch.call(that, r) }, res) },
// Check if diff is applicable to obj...
//