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

Function reverseBody

packages/effect/src/SchemaAST.ts:4913–4928  ·  view source on GitHub ↗
(body: AST, edge: Suspend["thunk"])

Source from the content-addressed store, hash-verified

4911}
4912
4913function reverseBody(body: AST, edge: Suspend["thunk"]): AST {
4914 if (types.get(body) !== body) return stripEncoding(flip(body))
4915 const existing = reversed.get(body)
4916 if (existing) return existing
4917 // A projected body can close its own cycle if all suspended edges lead back here
4918 // and reversing it preserves the checks and declaration callbacks.
4919 if (canReuse(body, edge)) {
4920 reversed.set(body, body)
4921 return body
4922 }
4923 const out = stripEncoding(flip(body))
4924 // The first reversal can discard checks. Further reversals can reuse the pair.
4925 if (reprojected.has(body) && !reversed.has(out)) reversed.set(out, body)
4926 reprojected.add(out)
4927 return out
4928}
4929
4930function fromConst<const T>(
4931 ast: AST,

Callers 1

projectFunction · 0.85

Calls 7

stripEncodingFunction · 0.85
canReuseFunction · 0.85
flipFunction · 0.70
getMethod · 0.65
setMethod · 0.65
hasMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected