MCPcopy Create free account
hub / github.com/Effect-TS/effect / encodeTo

Function encodeTo

packages/effect/src/Schema.ts:5882–5894  ·  view source on GitHub ↗
(
  to: To,
  transformation?: {
    readonly decode: SchemaGetter.Getter<From["Encoded"], To["Type"], RD>
    readonly encode: SchemaGetter.Getter<To["Type"], From["Encoded"], RE>
  }
)

Source from the content-addressed store, hash-verified

5880 }
5881): (from: From) => decodeTo<From, To, RD, RE>
5882export 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"]`.

Callers 2

withDecodingDefaultTypeFunction · 0.85

Calls 1

decodeToFunction · 0.70

Tested by

no test coverage detected