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

Function precompiledKeyOf

ark/schema/units.ts:476–489  ·  view source on GitHub ↗
(root: BaseRoot)

Source from the content-addressed store, hash-verified

474// helpers and node layout it calls into, is never bound to a node: a key it
475// doesn't match falls back to compiling it
476const precompiledKeyOf = (root: BaseRoot): string => {
477 let childCounts = ""
478 for (const id in root.byId) {
479 const node = root.byId[id]
480 childCounts += `${node.children.length}${node.is("optional") && node.defaultsUndefined ? "u" : ""},`
481 if (node.is("structure") && node.order)
482 childCounts += `[${node.inOrder.map(prop => node.props.indexOf(prop))}]`
483 }
484 const content =
485 root.hash.includes(`"$ark.`) ? keyRegisteredNames(root) : root.hash
486 return hashOf(
487 `${arkUtilVersion}\n${content}\n${childCounts}\n${$ark.sets !== undefined}`
488 )
489}
490
491// registered names and minified function names vary by program
492const keyRegisteredNames = (root: BaseRoot): string => {

Callers 2

bindRegisteredUnitsFunction · 0.85
keyOfFunction · 0.85

Calls 4

hashOfFunction · 0.90
keyRegisteredNamesFunction · 0.85
isMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected