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

Method load

ark/aot/graph.ts:1408–1437  ·  view source on GitHub ↗
(id: string, specifier: string)

Source from the content-addressed store, hash-verified

1406 }
1407
1408 private load(id: string, specifier: string): SourceModule | ImportTarget {
1409 const source = this.host.readFile(id)
1410 if (source === undefined) {
1411 return {
1412 kind: "unresolved",
1413 message: `${this.pathOf(id)} cannot be read`
1414 }
1415 }
1416 if (id.endsWith(".json")) {
1417 try {
1418 return {
1419 kind: "json",
1420 id,
1421 value: parseJsonText(source, this.pathOf(id))
1422 }
1423 } catch {
1424 return {
1425 kind: "unresolved",
1426 message: `${this.pathOf(id)} is not valid JSON`
1427 }
1428 }
1429 }
1430 if (!/\.[cm]?[jt]sx?$/.test(id)) {
1431 return {
1432 kind: "unresolved",
1433 message: `\`${specifier}\` is not a JavaScript or TypeScript module`
1434 }
1435 }
1436 return new SourceModule(id, source, this.pathOf(id))
1437 }
1438
1439 dependenciesOf(id: string): string[] {
1440 // a Set iterates in insertion order, entries added as it goes included,

Callers 8

moduleOfMethod · 0.95
resolveMethod · 0.95
createLayersFunction · 0.45
parity.test.tsFile · 0.45
bundlerResolverOfFunction · 0.45
loadedFunction · 0.45
resolveIdFunction · 0.45
preloadSearchFunction · 0.45

Calls 4

pathOfMethod · 0.95
parseJsonTextFunction · 0.90
readFileMethod · 0.80
testMethod · 0.80

Tested by 1

resolveIdFunction · 0.36