From 3ffbe78f573c44126aef51b2ffc22d9a0e5c3328 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 27 Aug 2018 01:48:12 +0300 Subject: [PATCH] docs + some tweaks... Signed-off-by: Alex A. Naanou --- README.md | 4 +++- diff.js | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b54c0e5..596fada 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,9 @@ The `path` is a `"/"` or `"\"` separated string that supports the following item *Note that `"**"` is a special case in that it can not be combined with other patterns above (e.g. in `"a|**"` the string `"**"` is treated literally and has not special meaning).* `diff.merge(diff) -> diff` -XXX +Generate a merged *diff* containing the changes from both diff object. + +*Note that this method currently simply concatenates the changes of two diff objects together, at this point no effort is made to optimize the new change list (changes can be redundant or canceling but there should not be any conflicts unless a merged diff is missing or is out of order).* `diff.end() -> diff` Return the *parent diff* that was used to generate the current *child diff* or the current diff if there is not parent. diff --git a/diff.js b/diff.js index 123f48a..f6cc674 100644 --- a/diff.js +++ b/diff.js @@ -2180,6 +2180,16 @@ var DiffClassPrototype = { // ...currently the context for most things is .constructor.types // which is global this makes anything that any handler does not // local to a particular diff instance... +// XXX patching should be possible with a simple empty object... +// ...not sure how to create the path elements though... +// this would make optimizing .merge(..) simple: +// var diff = x.merge(y) +// // reference -- the unchanged section of the input... +// var pre = diff +// .reverse() +// .patch() +// var post = diff.patch(ref) +// var optimized = Diff(pre, post) var DiffPrototype = { // system meta information... get format(){ @@ -2197,6 +2207,7 @@ var DiffPrototype = { placeholders: null, options: null, diff: null, + timestamp: null, parent: null, @@ -2220,6 +2231,8 @@ var DiffPrototype = { : options.tree_diff ? diff.diff(A, B, options) : diff.flatten(diff.diff(A, B, options), options) + + this.timestamp = Date.now() }, // XXX should this be a deep copy???