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

Function precompileRoot

ark/schema/units.ts:155–170  ·  view source on GitHub ↗
(
	root: BaseNode,
	references: readonly BaseNode[]
)

Source from the content-addressed store, hash-verified

153
154// a deferred Type's nodes aren't bound to another Type's unit
155export const precompileRoot = (
156 root: BaseNode,
157 references: readonly BaseNode[]
158): void => {
159 const unbound: UnboundTraversals = new Map()
160 for (const reference of references) {
161 if (reference === root || !reference.c.preJit) continue
162 for (const id in reference.byId) unbound.set(reference.byId[id], undefined)
163 }
164 // an apply checking data uncompiled to write in place reads no copy
165 for (const node of $ark.inPlace?.checking ?? []) unbound.set(node, undefined)
166 unbound.delete(root)
167 precompile(references, undefined, unbound, root)
168 // what an apply writing in place reads rather than compiling again
169 if ($ark.inPlace) root.c.unbound = unbound
170}
171
172export const precompileInPlace = (
173 root: BaseRoot,

Callers 1

jitFunction · 0.90

Calls 3

precompileFunction · 0.70
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected