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

Function initRootApply

ark/schema/node.ts:875–907  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

873 }
874
875 initRootApply(): RootApply {
876 if (this.c.preJit) {
877 if (this.checksUncompiled) {
878 const rootApply = this.createRootApply()
879 // marked used once it returns, so an allows it calls doesn't compile
880 const apply: RootApply = (data, onFail) => {
881 const result = rootApply(data, onFail)
882 this.c.usedPreJit = true
883 return result
884 }
885 const checked =
886 $ark.inPlace ?
887 $ark.inPlace.checkedUncompiled(this as never, apply)
888 : apply
889 if (checked) return checked
890 }
891 this.$.jit(this)
892 }
893 const compiled =
894 (this.unitFn || $ark.inPlace?.writesInPlace(this as never)) &&
895 this.isRoot() &&
896 canJit(this.$.cfg) &&
897 tryJit(() =>
898 compileRootApply($ark.inPlace?.applied(this as never) ?? this)
899 )
900 if (compiled) return (this.c.rootApply = compiled)
901 if (
902 (this.unitFn || (canJit(this.$.cfg) && !Object.isExtensible(this))) &&
903 this.isRoot()
904 )
905 $ark.inPlace?.unbindCompiled(this as never)
906 return (this.c.rootApply = this.createRootApply())
907 }
908
909 protected createRootApply(): RootApply {
910 const byErrors = rootApplyRuntimeOf(this.$.cfg)

Callers

nothing calls this directly

Calls 7

canJitFunction · 0.90
tryJitFunction · 0.90
compileRootApplyFunction · 0.85
checkedUncompiledMethod · 0.80
writesInPlaceMethod · 0.80
unbindCompiledMethod · 0.80
appliedMethod · 0.65

Tested by

no test coverage detected