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

Function bindModuleLazily

ark/schema/scope.ts:1259–1272  ·  view source on GitHub ↗
(
	module: InternalModule,
	$: BaseScope
)

Source from the content-addressed store, hash-verified

1257}
1258
1259const bindModuleLazily = (
1260 module: InternalModule,
1261 $: BaseScope
1262): InternalModule => {
1263 const bound = new RootModule({})
1264 const resolve = (k: string) => {
1265 const resolution = module[k]
1266 return hasArkKind(resolution, "module") ?
1267 bindModuleLazily(resolution, $)
1268 : finalizeExport($, $.bindRef(resolution as BaseRoot | GenericRoot))
1269 }
1270 for (const k in module) defineLazily(bound, k, resolve, isFinalResolution)
1271 return bound as never
1272}
1273
1274/**
1275 * whether a module's member can hold `resolution`: an alias referencing a

Callers 1

resolveFunction · 0.85

Calls 1

defineLazilyFunction · 0.90

Tested by

no test coverage detected