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

Function firstChildToDescendant

app/utilities/jsonColumnView.ts:95–117  ·  view source on GitHub ↗
(
  ancestor: JSONHeroPath,
  descendant: JSONHeroPath
)

Source from the content-addressed store, hash-verified

93}
94
95export function firstChildToDescendant(
96 ancestor: JSONHeroPath,
97 descendant: JSONHeroPath
98): string | undefined {
99 const ancestorPathComponents = ancestor.components.map((component) =>
100 component.toString()
101 );
102 const descendantPathComponents = descendant.components.map((component) =>
103 component.toString()
104 );
105
106 const pathComponents = [];
107
108 for (let index = 0; index < descendantPathComponents.length; index++) {
109 const descendantPathComponent = descendantPathComponents[index];
110
111 if (ancestorPathComponents.length >= index) {
112 pathComponents.push(descendantPathComponent);
113 }
114 }
115
116 return pathComponents.join(".");
117}
118
119export function pathToDescendant(
120 ancestor: string,

Callers 1

JsonColumnViewProviderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected