mirror of
https://github.com/flynx/diff.js.git
synced 2025-10-29 02:50:10 +00:00
working on .filter(path)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
8b07ea9487
commit
e5489b51a8
29
diff.js
29
diff.js
@ -2133,6 +2133,7 @@ var DiffPrototype = {
|
|||||||
|
|
||||||
// path filter (non-function)...
|
// path filter (non-function)...
|
||||||
if(!(filter instanceof Function)){
|
if(!(filter instanceof Function)){
|
||||||
|
// normalize path...
|
||||||
// format:
|
// format:
|
||||||
// [
|
// [
|
||||||
// '**' | [ .. ],
|
// '**' | [ .. ],
|
||||||
@ -2152,6 +2153,7 @@ var DiffPrototype = {
|
|||||||
: res[n].push(e)
|
: res[n].push(e)
|
||||||
return res
|
return res
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// min length...
|
// min length...
|
||||||
var min = path
|
var min = path
|
||||||
.reduce(function(l, e){
|
.reduce(function(l, e){
|
||||||
@ -2161,17 +2163,22 @@ var DiffPrototype = {
|
|||||||
var test = function(p, pattern, path){
|
var test = function(p, pattern, path){
|
||||||
return p == '**' ?
|
return p == '**' ?
|
||||||
// compare next pattern section and path...
|
// compare next pattern section and path...
|
||||||
cmp(pattern[0], path.slice(0, next.length))
|
(cmp(pattern[0], path.slice(0, next.length))
|
||||||
// shift path and test...
|
// next pattern/path section
|
||||||
// XXX need to stop if we run put of path...
|
// XXX need to stop if we run put of path or pattern...
|
||||||
|| (test(p,
|
&& test(pattern[1],
|
||||||
pattern,
|
pattern.slice(2),
|
||||||
path.slice(1))
|
path.slice(next.length)))
|
||||||
// shift to next pattern section...
|
// shift path and test...
|
||||||
// XXX need to stop if we run put of pattern...
|
// XXX need to stop if we run put of path...
|
||||||
&& test(pattern[1],
|
|| (test(p,
|
||||||
pattern.slice(2),
|
pattern,
|
||||||
path.slice(pattern[0].length)))
|
path.slice(1))
|
||||||
|
// shift to next pattern section...
|
||||||
|
// XXX need to stop if we run put of pattern...
|
||||||
|
&& test(pattern[1],
|
||||||
|
pattern.slice(2),
|
||||||
|
path.slice(pattern[0].length)))
|
||||||
: cmp(pattern[0], path)
|
: cmp(pattern[0], path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user