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

Method pushRootBranch

ark/type/parser/reduce/dynamic.ts:181–214  ·  view source on GitHub ↗
(token: BranchOperator)

Source from the content-addressed store, hash-verified

179 }
180
181 pushRootBranch(token: BranchOperator): void {
182 this.assertRangeUnset()
183 this.applyPrefixes()
184 const root = this.root!
185 this.root = undefined
186
187 const l = this.branches.intersection
188 this.branches.intersection = l?.rawAnd(root) ?? root
189 if (l) checkWrittenIntersection(this.branches.intersection, l, root)
190
191 if (token === "&") return
192
193 const operand = this.branches.intersection
194 this.branches.intersection = null
195 if (
196 !this.branches.union &&
197 operand.is("unit") &&
198 isEmptyObject(operand.meta)
199 )
200 (this.branches.units ??= []).push(operand)
201 else {
202 this.unionUnits()
203 this.branches.union = this.branches.union?.rawOr(operand) ?? operand
204 }
205
206 if (token === "|") return
207
208 this.unionUnits()
209
210 this.branches.pipe =
211 this.branches.pipe?.rawPipeOnce(this.branches.union!) ??
212 this.branches.union
213 this.branches.union = null
214 }
215
216 parseUntilFinalizer(): RootedRuntimeState {
217 return parseUntilFinalizer(new RuntimeState(this.sc, this.ctx))

Callers 2

finalizeBranchesMethod · 0.95
parseOperatorFunction · 0.80

Calls 7

assertRangeUnsetMethod · 0.95
applyPrefixesMethod · 0.95
unionUnitsMethod · 0.95
checkWrittenIntersectionFunction · 0.90
isEmptyObjectFunction · 0.90
isMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected