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

Function encodeTo

packages/effect/src/Schema.ts:5693–5705  ·  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

5691 }
5692): (from: From) => decodeTo<From, To, RD, RE>
5693export function encodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(
5694 to: To,
5695 transformation?: {
5696 readonly decode: SchemaGetter.Getter<From["Encoded"], To["Type"], RD>
5697 readonly encode: SchemaGetter.Getter<To["Type"], From["Encoded"], RE>
5698 }
5699) {
5700 return (from: From): decodeTo<From, To, RD, RE> => {
5701 return transformation ?
5702 decodeTo<From, To, RD, RE>(from, transformation)(to) :
5703 decodeTo<From>(from)(to)
5704 }
5705}
5706
5707/**
5708 * Applies a transformation to a schema's encoded type, creating a new schema where encoding/decoding

Callers 2

withDecodingDefaultTypeFunction · 0.85

Calls 1

decodeToFunction · 0.70

Tested by

no test coverage detected