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

Function schemaPathFromPath

app/components/JsonSchemaViewer.tsx:40–54  ·  view source on GitHub ↗
(path: JSONHeroPath | string)

Source from the content-addressed store, hash-verified

38}
39
40function schemaPathFromPath(path: JSONHeroPath | string): JSONHeroPath {
41 const heroPath = typeof path === "string" ? new JSONHeroPath(path) : path;
42
43 if (heroPath.isRoot) {
44 return heroPath;
45 }
46
47 return heroPath.components.slice(1).reduce((acc, component) => {
48 if (component.isArray) {
49 return acc.child("items");
50 } else {
51 return acc.child("properties").child(component.toString());
52 }
53 }, new JSONHeroPath("$"));
54}

Callers 1

JsonSchemaViewerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected