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

Function referenceOf

ark/schema/units.ts:1148–1157  ·  view source on GitHub ↗
(node: BaseNode, id: NodeId)

Source from the content-addressed store, hash-verified

1146
1147// nearest first through what node references, as an alias can replace a node sharing its id
1148const referenceOf = (node: BaseNode, id: NodeId): BaseNode | undefined => {
1149 if (node.c.byId) return node.byId[id]
1150 const queued = new Set<BaseNode>([node])
1151 for (const reference of queued) {
1152 if (reference.hasAlias) return node.byId[id]
1153 if (reference.id === id) return reference
1154 for (const child of reference.children) queued.add(child)
1155 for (const other of reference.otherRefs) queued.add(other)
1156 }
1157}
1158
1159const isPatternInstanceIn = (node: BaseNode, value: RegExp): boolean => {
1160 for (const id in node.byId) {

Callers 1

compileContentFunction · 0.85

Calls 1

addMethod · 0.45

Tested by

no test coverage detected