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

Function replayedJsonSchema

ark/type/runtime.ts:664–682  ·  view source on GitHub ↗
(
	write: () => JsonSchema,
	byTarget: readonly ((() => JsonSchema) | 0)[],
	// each target's, then the default's
	replays: readonly (((fallBack: FallBack) => JsonSchema) | 0)[]
)

Source from the content-addressed store, hash-verified

662// a baked schema written again with the fallback a call passes, as the build
663// recorded arktype writing it; a target's replay is 0 where it has none
664export const replayedJsonSchema = (
665 write: () => JsonSchema,
666 byTarget: readonly ((() => JsonSchema) | 0)[],
667 // each target's, then the default's
668 replays: readonly (((fallBack: FallBack) => JsonSchema) | 0)[]
669): ((opts?: JsonSchemaOptions) => JsonSchema) =>
670 freeze((opts?: JsonSchemaOptions) => {
671 const target = bakedTargetOf(opts, true)
672 const fallback = opts?.fallback
673 // a nullish fallback names no handler
674 if (fallback === undefined || fallback === null) {
675 const written = target === undefined ? write : byTarget[target]
676 return written ? written() : throwError(bakedJsonSchemaOptionsMessage)
677 }
678 const replay = replays[target ?? byTarget.length]
679 return replay ?
680 replay(fallingBackTo(fallback))
681 : throwError(bakedJsonSchemaOptionsMessage)
682 })
683
684// arktype calls a function for every code, else an object's handler for the
685// code or its default, else the configured one

Callers 1

fallbacks.test.tsFile · 0.90

Calls 5

throwErrorFunction · 0.90
bakedTargetOfFunction · 0.85
replayFunction · 0.85
fallingBackToFunction · 0.85
writtenFunction · 0.70

Tested by

no test coverage detected