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

Method packageNameOf

ark/aot/graph.ts:1389–1406  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

1387
1388 // e.g. `arksets` for a module a workspace links from its source
1389 packageNameOf(id: string): string | undefined {
1390 const dir = dirname(id)
1391 if (dir in this.packageNamesByDir) return this.packageNamesByDir[dir]
1392 const manifestPath = join(dir, "package.json")
1393 const manifest = this.host.readFile(manifestPath)
1394 let name: string | undefined
1395 if (manifest !== undefined) {
1396 try {
1397 name = parsePackageManifest(manifest, manifestPath).name
1398 } catch {
1399 // one that doesn't parse names nothing
1400 }
1401 }
1402 return (this.packageNamesByDir[dir] =
1403 manifest !== undefined ? name
1404 : dir === dirname(dir) ? undefined
1405 : this.packageNameOf(dir))
1406 }
1407
1408 private load(id: string, specifier: string): SourceModule | ImportTarget {
1409 const source = this.host.readFile(id)

Callers 2

calledParamOfMethod · 0.80
checkStandaloneMethod · 0.80

Calls 3

parsePackageManifestFunction · 0.90
joinFunction · 0.85
readFileMethod · 0.80

Tested by

no test coverage detected