(compiler: Compiler, ast: SchemaAST.AST)
| 926 | } |
| 927 | |
| 928 | function runWithCompiler<T, R>(compiler: Compiler, ast: SchemaAST.AST) { |
| 929 | let parser: Parser |
| 930 | return (input: unknown, options?: SchemaAST.ParseOptions): Effect.Effect<T, SchemaIssue.Issue, R> => { |
| 931 | const result = (parser ??= compiler(ast))( |
| 932 | input, |
| 933 | options ?? SchemaAST.defaultParseOptions |
| 934 | ) |
| 935 | if (result === InternalParser.sameExit) { |
| 936 | return Effect.succeed(input) as Effect.Effect<T, SchemaIssue.Issue, R> |
| 937 | } |
| 938 | if (!effectIsExit(result)) { |
| 939 | return Effect.flatMapEager(result, getValue) |
| 940 | } |
| 941 | return (result as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args] === |
| 942 | InternalParser.missing |
| 943 | ? getValue(InternalParser.missing) |
| 944 | : result as Effect.Effect<T, SchemaIssue.Issue, R> |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | function asPromise<T, E>( |
| 949 | parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue> |
no test coverage detected