From 67f0e02669c1a74e4780a8967826ffdef8abf5d1 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 22 Aug 2018 02:06:03 +0300 Subject: [PATCH] experimenting with diff actions... Signed-off-by: Alex A. Naanou --- diff.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/diff.js b/diff.js index 324d122..3639e4c 100644 --- a/diff.js +++ b/diff.js @@ -2122,6 +2122,29 @@ var DiffPrototype = { unpatch: function(obj){ return this.reverse().patch(obj) }, + // XXX .filter(..) -- keep only part of the changes and generate a new diff... + // ...should accept a path pattern (glob) as well as a function... + filter: function(filter){ + var res = this.clone() + + // path filter... + if(!(filter instanceof Function)){ + var path = filter instanceof Array ? filter : [filter] + + filter = function(change, i, lst){ + // XXX + } + } + + // XXX should we add filter to options or at least set a .filtered attr??? + // ...or maybe a reference to the original diff... + // ...might event implement a jQuery-like .end() + + res.diff = res.diff.filter(filter.bind(this)) + + return res + }, + // XXX need to normalize .diff and .options... json: function(){ return {