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

Method elsewhereOf

ark/aot/graph.ts:5392–5415  ·  view source on GitHub ↗
(
		module: SourceModule,
		holder: Binding | string,
		depth: number
	)

Source from the content-addressed store, hash-verified

5390 // import of it, of an alias exported in its place or of a module
5391 // re-exporting it
5392 elsewhereOf(
5393 module: SourceModule,
5394 holder: Binding | string,
5395 depth: number
5396 ): Elsewhere | undefined {
5397 if (!this.view) return
5398 const isName = typeof holder === "string"
5399 const key = isName ? module : holder
5400 let byDepth = this.elsewhereByHolder.get(key)
5401 if (!byDepth) this.elsewhereByHolder.set(key, (byDepth = new Map()))
5402 const depthKey = isName ? `${depth}:${holder}` : depth
5403 let result = byDepth.get(depthKey)
5404 if (result === undefined) {
5405 const held = heldAs(depth)
5406 result =
5407 this.findElsewhere(
5408 isName ?
5409 [[module, holder, held]]
5410 : this.exportsHolding(holder, module, held)
5411 ) ?? null
5412 byDepth.set(depthKey, result)
5413 }
5414 return result ?? undefined
5415 }
5416
5417 private findElsewhere(exports: HeldExport[]): Elsewhere | undefined {
5418 const seen = new Set<string>()

Callers 2

writtenElsewhereInMethod · 0.80
fixedDepthOfBindingMethod · 0.80

Calls 5

findElsewhereMethod · 0.95
exportsHoldingMethod · 0.95
heldAsFunction · 0.85
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected