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

Function decodeTo

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

Source from the content-addressed store, hash-verified

5578 }
5579): (from: From) => decodeTo<To, From, RD, RE>
5580export function decodeTo<To extends Constraint, From extends Constraint, RD = never, RE = never>(
5581 to: To,
5582 transformation?: {
5583 readonly decode: SchemaGetter.Getter<To["Encoded"], From["Type"], RD>
5584 readonly encode: SchemaGetter.Getter<From["Type"], To["Encoded"], RE>
5585 } | undefined
5586) {
5587 return (from: From) => {
5588 return make(
5589 SchemaAST.decodeTo(
5590 from.ast,
5591 to.ast,
5592 transformation ? SchemaTransformation.make(transformation) : SchemaTransformation.passthrough()
5593 ),
5594 {
5595 from,
5596 to
5597 }
5598 )
5599 }
5600}
5601
5602/**
5603 * Applies a transformation to a schema, creating a new schema with the same type but transformed encoding/decoding.

Callers 15

transformFunction · 0.70
encodeKeysFunction · 0.70
extendToFunction · 0.70
ArrayEnsureFunction · 0.70
decodeFunction · 0.70
encodeToFunction · 0.70
encodeFunction · 0.70
withDecodingDefaultKeyFunction · 0.70
withDecodingDefaultFunction · 0.70
OptionFromNullOrFunction · 0.70
OptionFromUndefinedOrFunction · 0.70
OptionFromNullishOrFunction · 0.70

Calls 2

makeFunction · 0.70
makeMethod · 0.65

Tested by

no test coverage detected