UNPKG

535 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) {
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
23function 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}