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

Function withVisitedTracking

packages/effect/src/Equal.ts:205–225  ·  view source on GitHub ↗

Helper to run comparison with proper visited tracking

(
  self: object,
  that: object,
  fn: () => boolean
)

Source from the content-addressed store, hash-verified

203
204/** Helper to run comparison with proper visited tracking */
205function withVisitedTracking(
206 self: object,
207 that: object,
208 fn: () => boolean
209): boolean {
210 const hasLeft = visitedLeft.has(self)
211 const hasRight = visitedRight.has(that)
212 // Check for circular references before adding
213 if (hasLeft && hasRight) {
214 return true // Both are circular at the same level
215 }
216 if (hasLeft || hasRight) {
217 return false // Only one is circular
218 }
219 visitedLeft.add(self)
220 visitedRight.add(that)
221 const result = fn()
222 visitedLeft.delete(self)
223 visitedRight.delete(that)
224 return result
225}
226
227const visitedLeft = new WeakSet<object>()
228const visitedRight = new WeakSet<object>()

Callers 1

compareObjectsFunction · 0.70

Calls 3

addMethod · 0.65
fnFunction · 0.50
hasMethod · 0.45

Tested by

no test coverage detected