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

Function fallingBackTo

ark/type/runtime.ts:686–695  ·  view source on GitHub ↗
(fallback: unknown)

Source from the content-addressed store, hash-verified

684// arktype calls a function for every code, else an object's handler for the
685// code or its default, else the configured one
686const fallingBackTo = (fallback: unknown): FallBack => {
687 const byCode = (
688 typeof fallback === "function" ?
689 { default: fallback }
690 : fallback) as Record<string, Fn | undefined>
691 return (code, ctx, configured) => {
692 const handler = byCode[code] ?? byCode.default ?? configured
693 return handler ? handler(ctx) : throwError(bakedJsonSchemaOptionsMessage)
694 }
695}
696
697type BakedJsonSchema = ReturnType<typeof bakedJsonSchema>
698

Callers 1

replayedJsonSchemaFunction · 0.85

Calls 2

throwErrorFunction · 0.90
handlerFunction · 0.85

Tested by

no test coverage detected