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

Function updateEdge

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

Source from the content-addressed store, hash-verified

1819 * @since 3.18.0
1820 */
1821export const updateEdge = <N, E, T extends Kind = "directed">(
1822 mutable: MutableGraph<N, E, T>,
1823 edgeIndex: EdgeIndex,
1824 f: (data: E) => E
1825): void => {
1826 assertMutable(mutable)
1827 const impl = graphImpl(mutable)
1828
1829 if (!impl.edges.has(edgeIndex)) {
1830 return
1831 }
1832
1833 const currentEdge = impl.edges.get(edgeIndex)!
1834 const newData = f(currentEdge.data)
1835 impl.edges.set(edgeIndex, new Edge({ ...currentEdge, data: newData }))
1836}
1837
1838/**
1839 * Transforms every node's data in a mutable graph in place using the provided

Callers

nothing calls this directly

Calls 6

assertMutableFunction · 0.85
graphImplFunction · 0.85
getMethod · 0.65
setMethod · 0.65
fFunction · 0.50
hasMethod · 0.45

Tested by

no test coverage detected