MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / generateNodesToPath

Function generateNodesToPath

app/utilities/jsonColumnView.ts:64–93  ·  view source on GitHub ↗
(
  json: unknown,
  path: string
)

Source from the content-addressed store, hash-verified

62}
63
64export 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
95export function firstChildToDescendant(
96 ancestor: JSONHeroPath,

Callers 1

PathLinkFunction · 0.90

Calls 1

iconForTypeFunction · 0.90

Tested by

no test coverage detected