( parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue, R> )
| 1022 | |
| 1023 | /** @internal */ |
| 1024 | export function asOption<T, E, R>( |
| 1025 | parser: (input: E, options?: SchemaAST.ParseOptions) => Effect.Effect<T, SchemaIssue.Issue, R> |
| 1026 | ): (input: E, options?: SchemaAST.ParseOptions) => Option.Option<T> { |
| 1027 | const parserExit = asExit(parser) |
| 1028 | return (input: E, options?: SchemaAST.ParseOptions) => { |
| 1029 | const exit = parserExit(input, options) |
| 1030 | if (Exit.isSuccess(exit)) { |
| 1031 | return Option.some(exit.value) |
| 1032 | } |
| 1033 | InternalSchemaCause.getSchemaIssueOrThrow(exit.cause, "Option adapter can only return none for schema issues") |
| 1034 | return Option.none() |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | function exitToOption<T>(exit: Exit.Exit<T, SchemaIssue.Issue>): Option.Option<T> { |
| 1039 | if (Exit.isSuccess(exit)) return Option.some(exit.value) |
no test coverage detected