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

Method packageModuleOf

ark/aot/graph.ts:6155–6174  ·  view source on GitHub ↗
(
		specifier: string,
		importer: SourceModule
	)

Source from the content-addressed store, hash-verified

6153 // a module of a package, which the build reads only for what its
6154 // functions may write
6155 private packageModuleOf(
6156 specifier: string,
6157 importer: SourceModule
6158 ): SourceModule | undefined {
6159 const id = this.host.resolve(specifier, importer.id)
6160 if (!id || !/\.[cm]?[jt]sx?$/.test(id)) return
6161 const loaded = this.modulesById[id]
6162 if (loaded) return loaded instanceof SourceModule ? loaded : undefined
6163 let result = this.packageModulesById.get(id)
6164 if (result === undefined) {
6165 const source = this.host.readFile(id)
6166 result =
6167 source === undefined ? null : (
6168 new SourceModule(id, source, this.pathOf(id))
6169 )
6170 if (result?.parseErrors.length) result = null
6171 this.packageModulesById.set(id, result)
6172 }
6173 return result ?? undefined
6174 }
6175
6176 private isPackageModule(module: SourceModule): boolean {
6177 return this.packageModulesById.get(module.id) === module

Callers 2

definitionOfMethod · 0.95
exportedDefinitionOfMethod · 0.95

Calls 6

pathOfMethod · 0.95
testMethod · 0.80
readFileMethod · 0.80
resolveMethod · 0.65
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected