MCPcopy Create free account
hub / github.com/arktypeio/arktype / _intersectNodes

Function _intersectNodes

ark/sets/intersections.ts:194–214  ·  view source on GitHub ↗
(
	l: BaseNode,
	r: BaseNode,
	ctx: IntersectionContext
)

Source from the content-addressed store, hash-verified

192 l.children.every((child, i) => sameBoundUnits(child, r.children[i])))
193
194const _intersectNodes = (
195 l: BaseNode,
196 r: BaseNode,
197 ctx: IntersectionContext
198) => {
199 const leftmostKind = l.precedence < r.precedence ? l.kind : r.kind
200 const implementation =
201 setImplementationsByKind[l.kind].intersections[r.kind] ??
202 setImplementationsByKind[r.kind].intersections[l.kind]
203 if (implementation === undefined) {
204 // should be two ConstraintNodes that have no relation
205 // this could also happen if a user directly intersects a Type and a ConstraintNode,
206 // but that is not allowed by the external function signature
207 return null
208 } else if (leftmostKind === l.kind) return implementation(l, r, ctx)
209 else {
210 let result = implementation(r, l, { ...ctx, invert: !ctx.invert })
211 if (result instanceof Disjoint) result = result.invert()
212 return result
213 }
214}
215
216const _pipeNodes = (
217 l: nodeOfKind<RootKind>,

Callers 2

intersections.tsFile · 0.85
_pipeNodesFunction · 0.85

Calls 1

invertMethod · 0.80

Tested by

no test coverage detected