MCPcopy Index your code
hub / github.com/Effect-TS/effect / encode

Function encode

packages/platform/src/ChannelSchema.ts:15–39  ·  view source on GitHub ↗
(
  schema: Schema.Schema<A, I, R>
)

Source from the content-addressed store, hash-verified

13 * @category constructors
14 */
15export const encode = <A, I, R>(
16 schema: Schema.Schema<A, I, R>
17) =>
18<IE = never, Done = unknown>(): Channel.Channel<
19 Chunk.Chunk<I>,
20 Chunk.Chunk<A>,
21 IE | ParseError,
22 IE,
23 Done,
24 Done,
25 R
26> => {
27 const encode = Schema.encode(Schema.ChunkFromSelf(schema))
28 const loop: Channel.Channel<Chunk.Chunk<I>, Chunk.Chunk<A>, IE | ParseError, IE, Done, Done, R> = Channel
29 .readWithCause({
30 onInput: (input: Chunk.Chunk<A>) =>
31 Channel.zipRight(
32 Channel.flatMap(encode(input), Channel.write),
33 loop
34 ),
35 onFailure: (cause: Cause.Cause<IE>) => Channel.failCause(cause),
36 onDone: Channel.succeed
37 })
38 return loop
39}
40
41/**
42 * @since 1.0.0

Callers 1

ChannelSchema.tsFile · 0.70

Calls 2

encodeMethod · 0.80
failCauseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…