| 51 | RequiredConversions<InputType, OutputType> |
| 52 | |
| 53 | function convert< |
| 54 | InputType extends ShapeOf<OutputType> & Record<string, unknown>, |
| 55 | OutputType extends ShapeOf<InputType>, |
| 56 | >( |
| 57 | conversions: Conversions<InputType, OutputType>, |
| 58 | input: InputType, |
| 59 | ): OutputType { |
| 60 | const c = conversions as Record<string, Conversion<InputType, OutputType>> |
| 61 | |
| 62 | return Object.fromEntries( |
| 63 | Object.keys(input).map((k: string) => { |
| 64 | const value = input[k] |
| 65 | return [k, c[k]?.(value as any) ?? value] |
| 66 | }), |
| 67 | ) as OutputType |
| 68 | } |
| 69 | |
| 70 | function convertPartial< |
| 71 | InputType extends ShapeOf<OutputType> & Record<string, unknown>, |