( json: unknown, path: string )
| 62 | } |
| 63 | |
| 64 | export function generateNodesToPath( |
| 65 | json: unknown, |
| 66 | path: string |
| 67 | ): Array<ColumnViewNode> { |
| 68 | const heroPath = new JSONHeroPath(path); |
| 69 | |
| 70 | const currentPathComponents: Array<PathComponent> = []; |
| 71 | |
| 72 | const nodes: Array<ColumnViewNode> = []; |
| 73 | |
| 74 | for (const component of heroPath.components) { |
| 75 | currentPathComponents.push(component); |
| 76 | |
| 77 | const currentPath = new JSONHeroPath(currentPathComponents); |
| 78 | |
| 79 | const info = inferType(currentPath.first(json)); |
| 80 | |
| 81 | const componentName = component.toString(); |
| 82 | |
| 83 | nodes.push({ |
| 84 | name: componentName, |
| 85 | title: componentName === "$" ? "root" : componentName, |
| 86 | id: currentPath.toString(), |
| 87 | icon: iconForType(info), |
| 88 | children: [], |
| 89 | }); |
| 90 | } |
| 91 | |
| 92 | return nodes; |
| 93 | } |
| 94 | |
| 95 | export function firstChildToDescendant( |
| 96 | ancestor: JSONHeroPath, |
no test coverage detected