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

Function nextMapped

packages/effect/src/Graph.ts:5193–5239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5191 }
5192
5193 const nextMapped = () => {
5194 while (stack.length > 0) {
5195 const [current, depth] = stack.pop()!
5196
5197 if (depths === undefined) {
5198 if (yielded.has(current)) {
5199 continue
5200 }
5201 } else if (depths.get(current) !== depth) {
5202 continue
5203 }
5204
5205 const nodeDataOption = getNode(graph, current)
5206 if (Option.isNone(nodeDataOption)) {
5207 continue
5208 }
5209
5210 if (depth < radius) {
5211 const neighbors = getTraversalNeighbors(graph, current, direction)
5212 for (let i = neighbors.length - 1; i >= 0; i--) {
5213 const neighbor = neighbors[i]
5214 const nextDepth = depth + 1
5215 if (depths === undefined) {
5216 if (!yielded.has(neighbor)) {
5217 stack.push([neighbor, nextDepth])
5218 }
5219 continue
5220 }
5221 const neighborDepth = depths.get(neighbor)
5222 if (neighborDepth === undefined || nextDepth < neighborDepth) {
5223 depths.set(neighbor, nextDepth)
5224 stack.push([neighbor, nextDepth])
5225 }
5226 }
5227 }
5228
5229 if (yielded.has(current)) {
5230 continue
5231 }
5232
5233 yielded.add(current)
5234
5235 return { done: false, value: f(current, nodeDataOption.value) }
5236 }
5237
5238 return { done: true, value: undefined } as const
5239 }
5240
5241 return { next: nextMapped }
5242 }

Callers

nothing calls this directly

Calls 9

getTraversalNeighborsFunction · 0.85
getDirectedNeighborsFunction · 0.85
pushMethod · 0.80
getMethod · 0.65
setMethod · 0.65
addMethod · 0.65
nextMethod · 0.65
fFunction · 0.50
hasMethod · 0.45

Tested by

no test coverage detected