(
to: To,
transformation?: {
readonly decode: SchemaGetter.Getter<From["Encoded"], To["Type"], RD>
readonly encode: SchemaGetter.Getter<To["Type"], From["Encoded"], RE>
}
)
| 5880 | } |
| 5881 | ): (from: From) => decodeTo<From, To, RD, RE> |
| 5882 | export function encodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>( |
| 5883 | to: To, |
| 5884 | transformation?: { |
| 5885 | readonly decode: SchemaGetter.Getter<From["Encoded"], To["Type"], RD> |
| 5886 | readonly encode: SchemaGetter.Getter<To["Type"], From["Encoded"], RE> |
| 5887 | } |
| 5888 | ) { |
| 5889 | return (from: From): decodeTo<From, To, RD, RE> => { |
| 5890 | return transformation ? |
| 5891 | decodeTo<From, To, RD, RE>(from, transformation)(to) : |
| 5892 | decodeTo<From>(from)(to) |
| 5893 | } |
| 5894 | } |
| 5895 | /** |
| 5896 | * Applies a transformation to a schema's encoded type, creating a new schema where encoding/decoding |
| 5897 | * operate on `S["Encoded"]` rather than `S["Type"]`. |
no test coverage detected