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

Function updateNode

packages/effect/src/Graph.ts:1783–1798  ·  view source on GitHub ↗
(
  mutable: MutableGraph<N, E, T>,
  index: NodeIndex,
  f: (data: N) => N
)

Source from the content-addressed store, hash-verified

1781 * @since 3.18.0
1782 */
1783export const updateNode = <N, E, T extends Kind = "directed">(
1784 mutable: MutableGraph<N, E, T>,
1785 index: NodeIndex,
1786 f: (data: N) => N
1787): void => {
1788 assertMutable(mutable)
1789 const impl = graphImpl(mutable)
1790
1791 if (!impl.nodes.has(index)) {
1792 return
1793 }
1794
1795 const currentData = impl.nodes.get(index)!
1796 const newData = f(currentData)
1797 impl.nodes.set(index, newData)
1798}
1799
1800/**
1801 * Updates a single edge's data by applying a transformation function.

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