UNPKG

569 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.addPath = addPath;
7exports.pathToArray = pathToArray;
8
9/**
10 * Given a Path and a key, return a new Path containing the new key.
11 */
12function 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
24function 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}