( ast: Union, parser: (i: number) => SchemaParser.Parser, candidates: ReadonlyArray<number>, input: unknown, options: ParseOptions )
| 3884 | } |
| 3885 | |
| 3886 | function parseUnionCandidates( |
| 3887 | ast: Union, |
| 3888 | parser: (i: number) => SchemaParser.Parser, |
| 3889 | candidates: ReadonlyArray<number>, |
| 3890 | input: unknown, |
| 3891 | options: ParseOptions |
| 3892 | ): Effect.Effect<unknown, SchemaIssue.Issue, any> { |
| 3893 | const state: UnionParserState = { |
| 3894 | ast, |
| 3895 | parser, |
| 3896 | input, |
| 3897 | out: undefined, |
| 3898 | successes: ast.options?.mode === "oneOf" ? [] : undefined, |
| 3899 | issues: undefined, |
| 3900 | options |
| 3901 | } |
| 3902 | const eff = parseUnion(state, candidates) |
| 3903 | if (!eff) { |
| 3904 | if (state.out) return state.out |
| 3905 | return Effect.fail(new SchemaIssue.AnyOf(ast, state.issues ?? [], input, options)) |
| 3906 | } |
| 3907 | if (effectIsExit(eff)) return resumeUnion(eff, state) |
| 3908 | // Reparse on later runs to avoid reusing mutable traversal state. |
| 3909 | let first = true |
| 3910 | return Effect.suspend(() => { |
| 3911 | if (!first) return parseUnionCandidates(ast, parser, candidates, input, options) |
| 3912 | first = false |
| 3913 | return resumeUnion(eff, state) |
| 3914 | }) |
| 3915 | } |
| 3916 | |
| 3917 | function resumeUnion( |
| 3918 | eff: Effect.Effect<void, SchemaIssue.Issue, any>, |
no test coverage detected