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

Function nodesAt

ark/aot/usage.ts:942–959  ·  view source on GitHub ↗
(module: SourceModule, spans: Span[])

Source from the content-addressed store, hash-verified

940 node.start === span.start && node.end === span.end
941
942const nodesAt = (module: SourceModule, spans: Span[]): Node[] => {
943 if (!spans.length) return []
944 const nodesByRange = new Map(
945 spans.map(span => [
946 `${span.start}:${span.end}`,
947 undefined as Node | undefined
948 ])
949 )
950 walk(module.program, node => {
951 const range = `${node.start}:${node.end}`
952 if (nodesByRange.has(range)) nodesByRange.set(range, node)
953 return spans.some(span => isIn(span, node))
954 })
955 return [...nodesByRange.values()].map(
956 node =>
957 node ?? escape(`${module.path} holds a validator its sites don't name`)
958 )
959}
960
961export const unprecompiled = (module: SourceModule): RuntimeModule => ({
962 module,

Callers 1

analyzeMethod · 0.85

Calls 6

walkFunction · 0.90
isInFunction · 0.85
escapeFunction · 0.70
mapMethod · 0.65
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected