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

Function withVisitedTracking

packages/effect/src/Hash.ts:508–516  ·  view source on GitHub ↗
(obj: object, fn: () => T)

Source from the content-addressed store, hash-verified

506const visitedObjects = new WeakSet<object>()
507
508function withVisitedTracking<T>(obj: object, fn: () => T): T {
509 if (visitedObjects.has(obj)) {
510 return string("[Circular]") as T
511 }
512 visitedObjects.add(obj)
513 const result = fn()
514 visitedObjects.delete(obj)
515 return result
516}

Callers 1

hashFunction · 0.70

Calls 4

stringFunction · 0.70
addMethod · 0.65
fnFunction · 0.50
hasMethod · 0.45

Tested by

no test coverage detected