MCPcopy Create free account
hub / github.com/Effect-TS/effect / reconstructTree

Function reconstructTree

packages/effect/src/unstable/cli/internal/config.ts:240–262  ·  view source on GitHub ↗
(
  tree: ConfigInternal.Tree,
  results: ReadonlyArray<any>
)

Source from the content-addressed store, hash-verified

238 * @internal
239 */
240export const reconstructTree = (
241 tree: ConfigInternal.Tree,
242 results: ReadonlyArray<any>
243): Record<string, any> => {
244 const output: Record<string, any> = {}
245
246 for (const key of Object.keys(tree)) {
247 InternalRecord.assignProperty(output, key, nodeValue(tree[key]))
248 }
249
250 return output
251
252 function nodeValue(node: ConfigInternal.Node): any {
253 switch (node._tag) {
254 case "Param":
255 return results[node.index]
256 case "Array":
257 return node.children.map((child) => nodeValue(child))
258 case "Nested":
259 return reconstructTree(node.tree, results)
260 }
261 }
262}

Callers 2

makeParserFunction · 0.90
nodeValueFunction · 0.85

Calls 1

nodeValueFunction · 0.85

Tested by

no test coverage detected