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

Method caseEntries

ark/type/match.ts:541–564  ·  view source on GitHub ↗
(
		entries: CaseEntry[]
	)

Source from the content-addressed store, hash-verified

539 }
540
541 protected caseEntries(
542 entries: CaseEntry[]
543 ): InternalChainedMatchParser | Match {
544 for (let i = 0; i < entries.length; i++) {
545 const [k, v] = entries[i]
546 if (k === "default") {
547 if (i !== entries.length - 1) {
548 throwParseError(
549 `default may only be specified as the last key of a switch definition`
550 )
551 }
552 return this.default(v)
553 }
554 if (typeof v !== "function") {
555 return throwParseError(
556 `Value for case "${k}" must be a function (was ${domainOf(v)})`
557 )
558 }
559
560 this.caseEntry(k, v)
561 }
562
563 return this
564 }
565
566 default(defaultCase: DefaultCase): Match {
567 if (typeof defaultCase === "function")

Callers 2

constructorMethod · 0.95
stringsMethod · 0.95

Calls 4

defaultMethod · 0.95
caseEntryMethod · 0.95
throwParseErrorFunction · 0.90
domainOfFunction · 0.90

Tested by

no test coverage detected