push
travis-ci
9 of 9 new or added lines in 1 file covered. (100.0%)
806 of 1632 relevant lines covered (49.39%)
8.03 hits per line
1 |
const parent = t => { |
1✔ |
2 |
if (t._c) {
|
1✔ |
3 |
if (t._cLevel === 1) { |
× |
4 |
return t._c
|
× |
5 |
} else {
|
|
6 |
t._p._cLevel = t._cLevel - 1
|
× |
7 |
t._p._c = t._c |
× |
8 |
return t._p
|
× |
9 |
} |
|
10 |
} else {
|
|
11 |
return t._p
|
1✔ |
12 |
} |
|
13 |
} |
|
14 |
|
|
15 |
const root = t => { |
1✔ |
16 |
var p = t
|
1✔ |
17 |
while (p) {
|
1✔ |
18 |
t = p |
1✔ |
19 |
p = parent(p) |
1✔ |
20 |
} |
|
21 |
return t
|
1✔ |
22 |
} |
|
23 |
|
|
24 |
const path = (t, real) => { |
1✔ |
25 |
const result = [] |
2✔ |
26 |
var parent = t
|
2✔ |
27 |
while (parent) {
|
2✔ |
28 |
if (parent._c && !real) {
|
6✔ |
29 |
let i = parent._cLevel |
× |
30 |
let p = parent |
× |
31 |
while (i--) {
|
× |
32 |
result.unshift(p.key) |
× |
33 |
p = p._p |
× |
34 |
} |
|
35 |
parent = parent._c |
× |
36 |
} else if (parent.key) { |
6✔ |
37 |
result.unshift(parent.key) |
4✔ |
38 |
parent = parent._p |
4✔ |
39 |
} else {
|
|
40 |
break
|
2✔ |
41 |
} |
|
42 |
} |
|
43 |
return result
|
2✔ |
44 |
} |
|
45 |
|
|
46 |
export { path, parent, root }
|