push
travis-ci
2 of 2 new or added lines in 1 file covered. (100.0%)
311 of 312 relevant lines covered (99.68%)
2091.33 hits per line
1 |
/*globals toString */
|
|
2 |
module.exports = traverse |
2✔ |
3 |
|
|
4 |
var fu = require('fu') |
2✔ |
5 |
|
|
6 |
function traverse(o, f, p) { |
2✔ |
7 |
var k
|
10,792✔ |
8 |
|
|
9 |
function make(parent) { |
2✔ |
10 |
return function (node) { |
86,896✔ |
11 |
var next = traverse(node, f, parent)
|
10,532✔ |
12 |
next === node || (next._fixmyjs = 1)
|
10,532✔ |
13 |
return next
|
10,532✔ |
14 |
} |
|
15 |
} |
|
16 |
|
|
|
if (o === undefined) { |
10,792✔ |
|
return o
|
× |
19 |
} |
|
20 |
|
|
21 |
for (k in o) { |
10,792✔ |
22 |
var call = make(o)
|
86,896✔ |
23 |
|
|
24 |
if (toString.call(o[k]) == '[object Object]') { |
86,896✔ |
25 |
o[k] = call(o[k]) |
9,894✔ |
26 |
} else if (Array.isArray(o[k])) { |
77,002✔ |
27 |
o[k] = fu.concatMap(call, o[k]) |
948✔ |
28 |
} |
|
29 |
} |
|
30 |
|
|
31 |
return f(o, p)
|
10,792✔ |
32 |
} |