1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.addPath = addPath;
|
7 | exports.pathToArray = pathToArray;
|
8 |
|
9 | /**
|
10 | * Given a Path and a key, return a new Path containing the new key.
|
11 | */
|
12 | function addPath(prev, key) {
|
13 | return {
|
14 | prev: prev,
|
15 | key: key
|
16 | };
|
17 | }
|
18 | /**
|
19 | * Given a Path, return an Array of the path keys.
|
20 | */
|
21 |
|
22 |
|
23 | function pathToArray(path) {
|
24 | var flattened = [];
|
25 | var curr = path;
|
26 |
|
27 | while (curr) {
|
28 | flattened.push(curr.key);
|
29 | curr = curr.prev;
|
30 | }
|
31 |
|
32 | return flattened.reverse();
|
33 | }
|