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

Function updateEdge

packages/effect/src/Graph.ts:2122–2141  ·  view source on GitHub ↗
(
  mutable: MutableGraph<N, E, T>,
  edgeIndex: EdgeIndex,
  f: (data: E) => E
)

Source from the content-addressed store, hash-verified

2120 * @since 3.18.0
2121 */
2122export const updateEdge = <N, E, T extends Kind = "directed">(
2123 mutable: MutableGraph<N, E, T>,
2124 edgeIndex: EdgeIndex,
2125 f: (data: E) => E
2126): void => {
2127 const impl = getMutableImplForMutation(mutable)
2128 internal.withTransformation(mutable, () => {
2129 if (!impl.edges.has(edgeIndex)) {
2130 return
2131 }
2132
2133 const currentEdge = impl.edges.get(edgeIndex)!
2134 const newData = f(currentEdge.data)
2135 impl.edges.set(edgeIndex, {
2136 source: currentEdge.source,
2137 target: currentEdge.target,
2138 data: newData
2139 })
2140 })
2141}
2142
2143/**
2144 * Transforms every node's data in a mutable graph in place using the provided

Callers

nothing calls this directly

Calls 5

hasMethod · 0.65
getMethod · 0.65
setMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected