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

Function toCodecDirect

packages/effect/src/encoding/SchemaBinary.ts:180–206  ·  view source on GitHub ↗
(schema: S, options?: Options)

Source from the content-addressed store, hash-verified

178 * @internal
179 */
180export function toCodecDirect<S extends Schema.Constraint>(schema: S, options?: Options): toCodec<S> {
181 const cache = options?.fingerprint === true ? directFingerprintCodecCache : directCodecCache
182 const cached = cache.get(schema)
183 if (cached !== undefined) return cached
184 const { exact, exitSuccess, layout, target } = compileTarget(schema)
185 if (!exact) {
186 if (!exitSuccess) return toCodec(schema, options)
187 const trusted: Trusted = { value: undefined }
188 const codec = assembleCodec<S>(
189 withExitSuccessDecode(target, trusted),
190 layout,
191 compileMode(layout, options?.fingerprint),
192 trusted,
193 true
194 )
195 cache.set(schema, codec)
196 return codec
197 }
198 const codec = assembleCodec<S>(
199 passThrough(target),
200 layout,
201 compileMode(layout, options?.fingerprint),
202 undefined
203 )
204 cache.set(schema, codec)
205 return codec
206}
207
208function assembleCodec<S extends Schema.Constraint>(
209 target: Schema.Constraint,

Callers

nothing calls this directly

Calls 8

compileTargetFunction · 0.85
assembleCodecFunction · 0.85
withExitSuccessDecodeFunction · 0.85
compileModeFunction · 0.85
passThroughFunction · 0.85
toCodecFunction · 0.70
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected