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

Function copyInto

packages/effect/src/Graph.ts:1679–1694  ·  view source on GitHub ↗
(graph: Graph<N, E, T>)

Source from the content-addressed store, hash-verified

1677 assertSameKind(self, that)
1678 return make(self.type)<N, E>((mutable) => {
1679 const copyInto = (graph: Graph<N, E, T>) => {
1680 const impl = internal.toImpl(graph)
1681 const indexMap = new Map<NodeIndex, NodeIndex>()
1682
1683 for (const [oldIndex, data] of impl.nodes) {
1684 indexMap.set(oldIndex, addNode(mutable, data))
1685 }
1686
1687 for (const edge of impl.edges.values()) {
1688 const sourceIndex = indexMap.get(edge.source)
1689 const targetIndex = indexMap.get(edge.target)
1690 if (sourceIndex !== undefined && targetIndex !== undefined) {
1691 addEdge(mutable, sourceIndex, targetIndex, edge.data)
1692 }
1693 }
1694 }
1695
1696 copyInto(self)
1697 copyInto(that)

Callers 1

Graph.tsFile · 0.85

Calls 4

addNodeFunction · 0.85
addEdgeFunction · 0.85
setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected