( entries: CaseEntry[] )
| 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") |
no test coverage detected