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

Function defining

ark/schema/shared/utils.ts:217–231  ·  view source on GitHub ↗
(define: () => t)

Source from the content-addressed store, hash-verified

215
216// a check left from a parse that threw would read its unresolved aliases
217export const defining = <t>(define: () => t): t => {
218 if (isResolutionFinal()) discardUnchecked()
219 inProgress.definitions++
220 let defined = false
221 try {
222 const result = define()
223 defined = true
224 return result
225 } finally {
226 inProgress.definitions--
227 // nor is its error another Type's, which whatever resolves next would
228 // throw if the checks waited for the next definition to discard them
229 if (!defined && isResolutionFinal()) discardUnchecked()
230 }
231}
232
233// a Type read while another node is built or described is nested in it
234export const composing = <t>(compose: () => t): t => {

Callers 5

readJsonSchemaFunction · 0.90
resolveUncachedFunction · 0.90
parseReturnedFunction · 0.90
parseOpenDefFunction · 0.90
encodeFunction · 0.90

Calls 3

isResolutionFinalFunction · 0.85
discardUncheckedFunction · 0.85
defineFunction · 0.50

Tested by

no test coverage detected