()
| 2954 | } |
| 2955 | |
| 2956 | const makeFallback = (): SchemaParser.Parser => { |
| 2957 | const expectedKeys = new Set<PropertyKey>( |
| 2958 | ast.propertySignatures.map((ps) => typeof ps.name === "number" ? globalThis.String(ps.name) : ps.name) |
| 2959 | ) |
| 2960 | const finishIndex = ( |
| 2961 | s: ObjectParserState, |
| 2962 | key: PropertyKey, |
| 2963 | k2: PropertyKey | typeof InternalParser.missing, |
| 2964 | inputValue: unknown, |
| 2965 | exitValue: Exit.Exit<unknown, SchemaIssue.Issue> |
| 2966 | ): Effect.Effect<void, SchemaIssue.Issue, any> => { |
| 2967 | if (exitValue._tag === "Failure") { |
| 2968 | return wrapPropertyKeyIssue(s, ast, key, exitValue) ?? Exit.void |
| 2969 | } |
| 2970 | const value = InternalParser.isSameExit(exitValue) |
| 2971 | ? inputValue |
| 2972 | : (exitValue as InternalParser.Success<unknown, SchemaIssue.Issue>)[InternalParser.args] |
| 2973 | if (k2 !== InternalParser.missing && value !== InternalParser.missing) { |
| 2974 | if ( |
| 2975 | hasProperties && |
| 2976 | (expectedKeys.has(key) || expectedKeys.has(typeof k2 === "number" ? globalThis.String(k2) : k2)) |
| 2977 | ) return Exit.void |
| 2978 | InternalRecord.assignProperty(s.out, k2, value) |
| 2979 | } |
| 2980 | return Exit.void |
| 2981 | } |
| 2982 | const parseIndex = ( |
| 2983 | s: ObjectParserState, |
| 2984 | key: PropertyKey, |
| 2985 | index: Index, |
| 2986 | exitKey?: Exit.Exit<unknown, SchemaIssue.Issue> |
| 2987 | ): Effect.Effect<void, SchemaIssue.Issue, any> => { |
| 2988 | if (!exitKey) { |
| 2989 | const eff = index.parserKey(key, s.options) |
| 2990 | if (!effectIsExit(eff)) { |
| 2991 | return Effect.flatMap(Effect.exit(eff), (exit) => parseIndex(s, key, index, exit)) |
| 2992 | } |
| 2993 | exitKey = eff |
| 2994 | } |
| 2995 | if (exitKey._tag === "Failure") { |
| 2996 | return wrapPropertyKeyIssue(s, ast, key, exitKey) ?? Exit.void |
| 2997 | } |
| 2998 | const k2 = InternalParser.isSameExit(exitKey) |
| 2999 | ? key |
| 3000 | : (exitKey as InternalParser.Success<PropertyKey, SchemaIssue.Issue>)[InternalParser.args] |
| 3001 | const inputValue = s.input[key] |
| 3002 | const result = index.parserValue(inputValue, s.options) |
| 3003 | return effectIsExit(result) |
| 3004 | ? finishIndex(s, key, k2, inputValue, result) |
| 3005 | : Effect.flatMap(Effect.exit(result), (exit) => finishIndex(s, key, k2, inputValue, exit)) |
| 3006 | } |
| 3007 | const parseStringIndex = ( |
| 3008 | s: ObjectParserState, |
| 3009 | key: PropertyKey, |
| 3010 | index: Index |
| 3011 | ): Effect.Effect<void, SchemaIssue.Issue, any> => { |
| 3012 | const inputValue = s.input[key] |
| 3013 | const result = index.parserValue(inputValue, s.options) |
nothing calls this directly
no test coverage detected