diff --git a/README.md b/README.md index 6341625..370f7a3 100644 --- a/README.md +++ b/README.md @@ -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') diff --git a/diff.js b/diff.js index ffc3b13..8fe9cc2 100644 --- a/diff.js +++ b/diff.js @@ -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... //