( entry: CompilerRegistry.Entry, options?: SchemaAST.ParseOptions )
| 1066 | } |
| 1067 | |
| 1068 | function makeSyncEntry<T>( |
| 1069 | entry: CompilerRegistry.Entry, |
| 1070 | options?: SchemaAST.ParseOptions |
| 1071 | ): (input: unknown, options?: SchemaAST.ParseOptions) => T { |
| 1072 | const decode = entry.decode |
| 1073 | let detailed: ((input: unknown, options?: SchemaAST.ParseOptions) => T) | undefined |
| 1074 | const run = decode === undefined |
| 1075 | ? (input: unknown, parseOptions = SchemaAST.defaultParseOptions): T => |
| 1076 | (detailed ??= makeDetailedSync<T>(entry))(input, parseOptions) |
| 1077 | : (input: unknown, parseOptions = SchemaAST.defaultParseOptions): T => { |
| 1078 | if (input === InternalParser.missing) { |
| 1079 | return (detailed ??= makeDetailedSync<T>(entry))(input, parseOptions) |
| 1080 | } |
| 1081 | let output: unknown |
| 1082 | try { |
| 1083 | output = decode(input, parseOptions) |
| 1084 | } catch (error) { |
| 1085 | InternalSchemaCause.getSchemaIssueOrThrow(Cause.die(error), "Sync adapter can only throw schema issues") |
| 1086 | throw error |
| 1087 | } |
| 1088 | if (output !== CompilerRegistry.invalid) return output as T |
| 1089 | return (detailed ??= makeDetailedSync<T>(entry))(input, parseOptions) |
| 1090 | } |
| 1091 | return withParseOptions(run, options) |
| 1092 | } |
| 1093 | |
| 1094 | function makeDetailedSync<T>( |
| 1095 | entry: CompilerRegistry.Entry |
no test coverage detected