Function
addNode
(node: ColumnViewNode, parentId?: string)
Source from the content-addressed store, hash-verified
| 554 | const nodesById: { [id: string]: NodeRecord } = {}; |
| 555 | |
| 556 | function addNode(node: ColumnViewNode, parentId?: string) { |
| 557 | const nodeRecord: NodeRecord = { |
| 558 | id: node.id, |
| 559 | node, |
| 560 | parentId, |
| 561 | children: [], |
| 562 | }; |
| 563 | |
| 564 | nodesById[node.id] = nodeRecord; |
| 565 | |
| 566 | if (node.children) { |
| 567 | node.children.forEach((child) => { |
| 568 | addNode(child, node.id); |
| 569 | }); |
| 570 | |
| 571 | nodeRecord.children = node.children.map((child) => child.id); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | addNode(rootNode); |
| 576 | |
Tested by
no test coverage detected