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

Function copyInto

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

Source from the content-addressed store, hash-verified

1414 assertSameKind(self, that)
1415 return make(self.type)<N, E>((mutable) => {
1416 const copyInto = (graph: Graph<N, E, T>) => {
1417 const impl = graphImpl(graph)
1418 const indexMap = new Map<NodeIndex, NodeIndex>()
1419
1420 for (const [oldIndex, data] of impl.nodes) {
1421 indexMap.set(oldIndex, addNode(mutable, data))
1422 }
1423
1424 for (const edge of impl.edges.values()) {
1425 const sourceIndex = indexMap.get(edge.source)
1426 const targetIndex = indexMap.get(edge.target)
1427 if (sourceIndex !== undefined && targetIndex !== undefined) {
1428 addEdge(mutable, sourceIndex, targetIndex, edge.data)
1429 }
1430 }
1431 }
1432
1433 copyInto(self)
1434 copyInto(that)

Callers 1

Graph.tsFile · 0.85

Calls 5

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

Tested by

no test coverage detected