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

Function mapEdges

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

Source from the content-addressed store, hash-verified

2234 * @since 3.18.0
2235 */
2236export const mapEdges = <N, E, T extends Kind = "directed">(
2237 mutable: MutableGraph<N, E, T>,
2238 f: (data: E) => E
2239): void => {
2240 const impl = getMutableImplForMutation(mutable)
2241 internal.withTransformation(mutable, () => {
2242 // Transform existing edge data in place
2243 for (const [index, edgeData] of impl.edges) {
2244 const newData = f(edgeData.data)
2245 impl.edges.set(index, {
2246 source: edgeData.source,
2247 target: edgeData.target,
2248 data: newData
2249 })
2250 }
2251 })
2252}
2253
2254/**
2255 * Swaps source and target nodes for every edge in a mutable graph.

Callers

nothing calls this directly

Calls 3

setMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected