push
travis-ci
18 of 18 new or added lines in 2 files covered. (100.0%)
984 of 1523 relevant lines covered (64.61%)
79.12 hits per line
1 |
// will combined lookup
|
|
2 |
const parent = t => { |
1✔ |
3 |
if (t.context) {
|
1,076✔ |
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
|
1,076✔ |
13 |
} |
|
14 |
} |
|
15 |
|
|
16 |
const root = t => { |
1✔ |
17 |
var p = t
|
335✔ |
18 |
while (p) {
|
335✔ |
19 |
t = p |
1,036✔ |
20 |
p = parent(p) |
1,036✔ |
21 |
} |
|
22 |
return t
|
335✔ |
23 |
} |
|
24 |
|
|
25 |
const path = t => { |
1✔ |
26 |
const result = [] |
254✔ |
27 |
var parent = t
|
254✔ |
28 |
while (parent) {
|
254✔ |
29 |
if (parent.context) {
|
757✔ |
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) { |
757✔ |
38 |
result.unshift(parent.key) |
503✔ |
39 |
parent = parent._p |
503✔ |
40 |
} else {
|
|
41 |
break
|
254✔ |
42 |
} |
|
43 |
} |
|
44 |
return result
|
254✔ |
45 |
} |
|
46 |
|
|
47 |
exports.path = path |
1✔ |
48 |
exports.parent = parent |
1✔ |
49 |
exports.root = root |
1✔ |