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

Function originOf

ark/aot/flat.ts:414–431  ·  view source on GitHub ↗
(
		binding: Binding | undefined
	)

Source from the content-addressed store, hash-verified

412 const result = new Map<string, Creation[]>()
413 const declaredIn = new Map(units.map(unit => [unit.specifier, unit]))
414 const originOf = (
415 binding: Binding | undefined
416 ): [specifier: string, name: string] | undefined => {
417 if (binding?.kind !== "import") return
418 const specifier = binding.declaration
419 if (
420 specifier.type !== "ImportSpecifier" ||
421 specifier.parent?.type !== "ImportDeclaration"
422 )
423 return
424 const source = specifier.parent.source.value
425 const target = parsed.get(source)
426 const entry = target?.scopes.exportsByName[exportNameOf(specifier.imported)]
427 if (entry?.kind !== "binding") return
428 return entry.binding.kind === "import" ?
429 originOf(entry.binding)
430 : [source, entry.binding.name]
431 }
432 const callsOf = new Map<string, number>()
433 for (const module of parsed.values()) {
434 for (const binding of Object.values(module.scopes.root.bindings)) {

Callers 1

creationsInFunction · 0.85

Calls 2

exportNameOfFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected