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, typename) {
|
13 | return {
|
14 | prev: prev,
|
15 | key: key,
|
16 | typename: typename
|
17 | };
|
18 | }
|
19 | /**
|
20 | * Given a Path, return an Array of the path keys.
|
21 | */
|
22 |
|
23 |
|
24 | function pathToArray(path) {
|
25 | var flattened = [];
|
26 | var curr = path;
|
27 |
|
28 | while (curr) {
|
29 | flattened.push(curr.key);
|
30 | curr = curr.prev;
|
31 | }
|
32 |
|
33 | return flattened.reverse();
|
34 | }
|