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

Function nodes

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

Source from the content-addressed store, hash-verified

5660 * @since 3.18.0
5661 */
5662export const nodes = <N, E, T extends Kind = "directed">(
5663 graph: Graph<N, E, T> | MutableGraph<N, E, T>
5664): NodeWalker<N> =>
5665 new Walker((f) => ({
5666 [Symbol.iterator]() {
5667 const nodeMap = graphImpl(graph).nodes
5668 const iterator = nodeMap.entries()
5669
5670 return {
5671 next() {
5672 const result = iterator.next()
5673 if (result.done) {
5674 return { done: true, value: undefined }
5675 }
5676 const [nodeIndex, nodeData] = result.value
5677 return { done: false, value: f(nodeIndex, nodeData) }
5678 }
5679 }
5680 }
5681 }))
5682
5683/**
5684 * Creates an iterator over all edge indices in the graph.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected