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

Function parseBranchTuple

ark/type/parser/tupleExpressions.ts:455–470  ·  view source on GitHub ↗
(def, ctx)

Source from the content-addressed store, hash-verified

453>
454
455const parseBranchTuple: IndexOneParser<BranchOperator> = (def, ctx) => {
456 assertTupleArity(def, def[1], 3)
457 if (def[2] === undefined)
458 return throwParseError(writeMissingRightOperandMessage(def[1], ""))
459
460 const l = ctx.$.parseOwn(def[0], ctx)
461 const r = ctx.$.parseOwn(def[2], ctx)
462 if (def[1] === "|") return ctx.$.node("union", { branches: [l, r] })
463 const result =
464 def[1] === "&" ?
465 intersectNodesRoot(l, r, ctx.$)
466 : pipeNodesRoot(l, r, ctx.$)
467 if (result instanceof Disjoint) return result.throw()
468 if (def[1] === "&") checkWrittenIntersection(result, l, r)
469 return result
470}
471
472const parseArrayTuple: IndexOneParser<"[]"> = (def, ctx) => {
473 assertTupleArity(def, "[]", 2)

Callers

nothing calls this directly

Calls 9

throwParseErrorFunction · 0.90
checkWrittenIntersectionFunction · 0.90
assertTupleArityFunction · 0.85
intersectNodesRootFunction · 0.85
pipeNodesRootFunction · 0.85
nodeMethod · 0.80
throwMethod · 0.65
parseOwnMethod · 0.45

Tested by

no test coverage detected