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

Function defer

ark/type/deferred.ts:1424–1439  ·  view source on GitHub ↗
(facts: Facts, $: InternalScope, resolve: () => BaseRoot)

Source from the content-addressed store, hash-verified

1422// equal definitions' one Type, as their nodes would make it. A kind and comma
1423// start each node's key, and nothing a definition is scanned to does
1424const defer = (facts: Facts, $: InternalScope, resolve: () => BaseRoot) => {
1425 const existing = $.nodesByKey.get(facts.key)
1426 if (existing && (!deferred.has(existing) || Object.isExtensible(existing)))
1427 return existing as never
1428 const { fn, c } = deferredCallable()
1429 const self = fn as BaseRoot
1430 Object.setPrototypeOf(self, shellProto)
1431 deferred.set(self, { facts, fn, c, $, resolve })
1432 $.nodesByKey.set(facts.key, self)
1433 // fixes the global config, as parsing a definition would
1434 if (!$ark.cfg) {
1435 void $.cfg
1436 recordFirstType(self, true)
1437 }
1438 return self as never
1439}
1440
1441// no scope but ark says what the scanned keywords are
1442const canDefer = ($: InternalScope) => {

Callers 4

deferUnionFunction · 0.85
deferred.tsFile · 0.85
instantiateFunction · 0.85
deferDefinitionFunction · 0.85

Calls 5

deferredCallableFunction · 0.90
recordFirstTypeFunction · 0.90
getMethod · 0.65
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected