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

Method appliedKindOfKey

ark/aot/graph.ts:4302–4346  ·  view source on GitHub ↗
(
		{ fn, args }: Application,
		module: SourceModule,
		kindOfKey: KindOfKey
	)

Source from the content-addressed store, hash-verified

4300 }
4301
4302 private appliedKindOfKey(
4303 { fn, args }: Application,
4304 module: SourceModule,
4305 kindOfKey: KindOfKey
4306 ): KindOfKey {
4307 const params = runtimeParamsOf(fn)
4308 const derived = new Map<Key, KindBits>()
4309 const result: KindOfKey = (key, keyModule) => {
4310 const index =
4311 "kind" in key && key.kind === "param" && key.declaration === fn ?
4312 params.findIndex(param => contains(param, key.id))
4313 : undefined
4314 // what fn declares, for the `T` passed, e.g. `N` in
4315 // `{ const N = T.or("null"); return N }`
4316 const anchor = anchorOf(key)
4317 if (
4318 index === undefined &&
4319 (keyModule !== module || anchor === fn || !contains(fn, anchor))
4320 )
4321 return kindOfKey(key, keyModule)
4322 let kind = derived.get(key)
4323 if (kind !== undefined) return kind
4324 // read while derived: a parameter holds what the call passes, else
4325 // what any call gives it
4326 kind =
4327 index === undefined ? kindOfKey(key, keyModule)
4328 : index === -1 ? kinds.data
4329 : this.patternKindOf(
4330 (key as Binding).id,
4331 params[index],
4332 args[index],
4333 module,
4334 result
4335 )
4336 derived.set(key, kind)
4337 kind =
4338 index === undefined ?
4339 this.keyKindOf(key, keyModule, result)
4340 : kind | this.writtenKindOf(key as Binding, module, result)
4341 derived.set(key, kind)
4342 return kind
4343 }
4344 this.bindingKindOfKeys.add(result)
4345 return result
4346 }
4347
4348 private literalOf(
4349 node: Node,

Callers 2

keyKindOfMethod · 0.95
literalOfMethod · 0.95

Calls 2

runtimeParamsOfFunction · 0.90
addMethod · 0.45

Tested by

no test coverage detected