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

Function everyNode

packages/effect/src/SchemaAST.ts:4696–4714  ·  view source on GitHub ↗
(root: AST, predicate: (ast: AST) => boolean, proven?: WeakSet<AST>)

Source from the content-addressed store, hash-verified

4694
4695// Suspensions are leaves in this walk. Only resolving a suspension may call its thunk.
4696function everyNode(root: AST, predicate: (ast: AST) => boolean, proven?: WeakSet<AST>): boolean {
4697 const nodes = new Set([root])
4698 for (const ast of nodes) {
4699 if (proven?.has(ast)) continue
4700 if (!predicate(ast)) return false
4701 if (!isSuspend(ast) && "recur" in ast) ast.recur(visit)
4702 }
4703 if (proven) {
4704 for (const ast of nodes) {
4705 proven.add(ast)
4706 }
4707 }
4708 return true
4709
4710 function visit(child: AST): AST {
4711 nodes.add(child)
4712 return child
4713 }
4714}
4715
4716const preservesShape = new WeakSet<AST>()
4717

Callers 2

projectChecksFunction · 0.85
canReuseFunction · 0.85

Calls 4

predicateFunction · 0.85
hasMethod · 0.65
recurMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected