1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.printPathArray = exports.pathToArray = exports.addPath = void 0;
|
4 |
|
5 |
|
6 |
|
7 | function addPath(prev, key, typename) {
|
8 | return { prev, key, typename };
|
9 | }
|
10 | exports.addPath = addPath;
|
11 |
|
12 |
|
13 |
|
14 | function pathToArray(path) {
|
15 | const flattened = [];
|
16 | let curr = path;
|
17 | while (curr) {
|
18 | flattened.push(curr.key);
|
19 | curr = curr.prev;
|
20 | }
|
21 | return flattened.reverse();
|
22 | }
|
23 | exports.pathToArray = pathToArray;
|
24 |
|
25 |
|
26 |
|
27 | function printPathArray(path) {
|
28 | return path
|
29 | .map(key => (typeof key === 'number' ? '[' + key.toString() + ']' : '.' + key))
|
30 | .join('');
|
31 | }
|
32 | exports.printPathArray = printPathArray;
|