push
travis-ci
759 of 1434 relevant lines covered (52.93%)
28.18 hits per line
1 |
// will combined lookup
|
|
2 |
const parent = t => { |
1✔ |
3 |
if (t.context) {
|
698✔ |
4 |
if (t.contextLevel === 1) { |
× |
5 |
return t.context
|
× |
6 |
} else {
|
|
7 |
t._p.contextLevel = t.contextLevel - 1
|
× |
8 |
t._p.context = t.context |
× |
9 |
return t._p
|
× |
10 |
} |
|
11 |
} else {
|
|
12 |
return t._p
|
698✔ |
13 |
} |
|
14 |
} |
|
15 |
|
|
16 |
const root = t => { |
1✔ |
17 |
var p = t
|
207✔ |
18 |
while (p) {
|
207✔ |
19 |
t = p |
698✔ |
20 |
p = parent(p) |
698✔ |
21 |
} |
|
22 |
return t
|
207✔ |
23 |
} |
|
24 |
|
|
25 |
const path = t => { |
1✔ |
26 |
const result = [] |
65✔ |
27 |
var parent = t
|
65✔ |
28 |
while (parent) {
|
65✔ |
29 |
if (parent.context) {
|
166✔ |
30 |
let i = parent.contextLevel |
× |
31 |
let p = parent |
× |
32 |
while (i--) {
|
× |
33 |
result.unshift(p.key) |
× |
34 |
p = p._p |
× |
35 |
} |
|
36 |
parent = parent.context |
× |
37 |
} else if (parent.key) { |
166✔ |
38 |
result.unshift(parent.key) |
101✔ |
39 |
parent = parent._p |
101✔ |
40 |
} else {
|
|
41 |
break
|
65✔ |
42 |
} |
|
43 |
} |
|
44 |
return result
|
65✔ |
45 |
} |
|
46 |
|
|
47 |
exports.path = path |
1✔ |
48 |
exports.parent = parent |
1✔ |
49 |
exports.root = root |
1✔ |