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

Function parseNarrowTuple

ark/type/parser/tupleExpressions.ts:515–526  ·  view source on GitHub ↗
(def, ctx)

Source from the content-addressed store, hash-verified

513// a tuple's predicate is a .narrow(), so it checks the output, after any
514// morphs and defaults, and a morph pipes to it
515export const parseNarrowTuple: IndexOneParser<":"> = (def, ctx) => {
516 assertTupleArity(def, ":", 3)
517 if (typeof def[2] !== "function") {
518 return throwParseError(
519 writeMalformedFunctionalExpressionMessage(":", def[2])
520 )
521 }
522 return ctx.$.parseOwn(def[0], ctx).rawConstrainOut(
523 "predicate",
524 def[2] as Predicate
525 )
526}
527
528const parseMetaTuple: IndexOneParser<"@"> = (def, ctx) => {
529 assertTupleArity(def, "@", 3, 4)

Callers

nothing calls this directly

Calls 4

throwParseErrorFunction · 0.90
assertTupleArityFunction · 0.85
parseOwnMethod · 0.45

Tested by

no test coverage detected