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

Function assignSteps

ark/schema/shared/compile.ts:598–620  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

596 const isTransformErrors = () =>
597 `typeof ${name} === "function" && ${name} instanceof ${this.ref(TransformErrors)}`
598 const assignSteps = () => {
599 const errN = `${name}ErrorCount`
600 if (nodes.slice(0, -1).some(node => node.tfCtx))
601 this.const(errN, `${this.ctx}.errN`)
602 for (let i = 0; i < steps.length; i++) {
603 const { node, signature, indexed } = steps[i]
604 const previous = nodes.slice(0, i)
605 const conditions = indexed && opts?.ownKey ? [opts.ownKey] : []
606 if (signature) {
607 conditions.push(
608 this.inv(signature, { arg: keyExpr!, kind: "Allows" })
609 )
610 }
611 if (previous.some(returnsTransformErrors))
612 conditions.push(`!(${isTransformErrors()})`)
613 if (previous.some(node => node.tfCtx))
614 conditions.push(`${this.ctx}.errN === ${errN}`)
615 const assignStep = () => assign(name, node, i === 0 ? input : name)
616 if (conditions.length) this.if(conditions.join(" && "), assignStep)
617 else assignStep()
618 }
619 return this
620 }
621 if (
622 steps.length === 1 &&
623 !steps[0].signature &&

Callers 1

tfKeyFunction · 0.85

Calls 6

isTransformErrorsFunction · 0.85
assignStepFunction · 0.85
constMethod · 0.80
ifMethod · 0.80
pushMethod · 0.45
invMethod · 0.45

Tested by

no test coverage detected