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

Method constructor

ark/aot/module.ts:58–97  ·  view source on GitHub ↗
(id: string, source: string, path: string, mappings?: string)

Source from the content-addressed store, hash-verified

56 private mappings: SourceMapMappings | undefined
57
58 constructor(id: string, source: string, path: string, mappings?: string) {
59 this.id = id
60 this.path = path
61 this.source = source
62 this.mappings = mappings ? decode(mappings) : undefined
63 const result = parseModule(id, source)
64 this.program = result.program
65 this.parseErrors = result.errors.map(e => e.message)
66 this.scopes = new ModuleScopes(this.program)
67 this.islands =
68 source.includes(islandMarker) ?
69 markedBy(
70 this.program,
71 source,
72 result.comments,
73 this.strayMarkers,
74 // what follows it is a reason, as `// @ark-runtime its shape is loaded`
75 comment => comment.split(/\s/, 1)[0] === islandMarker || undefined
76 ).map(([node]) => node)
77 : []
78 this.strategyMarks =
79 source.includes(strategyMarker) ?
80 markedBy(
81 this.program,
82 source,
83 result.comments,
84 this.strayStrategyMarkers,
85 markedStrategyOf
86 ).map(([node, name, comment]) => ({ node, name, comment }))
87 : []
88 this.allowDropNarrows =
89 source.includes(allowDropNarrowMarker) ?
90 dropNarrowSuppressionsOf(
91 this.program,
92 source,
93 result.comments,
94 offset => this.lineAndColumnOf(offset)[0]
95 )
96 : emptySuppressions
97 }
98
99 lineAndColumnOf(offset: number): [line: number, column: number] {
100 this.lineStarts ??= computeLineStarts(this.source)

Callers

nothing calls this directly

Calls 6

lineAndColumnOfMethod · 0.95
parseModuleFunction · 0.85
markedByFunction · 0.85
dropNarrowSuppressionsOfFunction · 0.85
mapMethod · 0.65
decodeFunction · 0.50

Tested by

no test coverage detected