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

Function encode

packages/effect/src/unstable/encoding/Sse.ts:436–457  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

434 * @since 4.0.0
435 */
436export const encode = <IE, Done>(): Channel.Channel<
437 NonEmptyReadonlyArray<string>,
438 IE,
439 void,
440 NonEmptyReadonlyArray<Event>,
441 IE | Retry,
442 Done
443> =>
444 Channel.fromTransform((upstream, _scope) =>
445 Effect.sync(() => {
446 let done = false
447 const pull = upstream.pipe(
448 Effect.map(Arr.map(encoder.write)),
449 Effect.catchFilter(Retry.filter as any, (retry: any) => {
450 done = true
451 return Effect.succeed(Arr.of(encoder.write(retry)))
452 }),
453 Pull.catchDone(() => Cause.done())
454 ) as Pull.Pull<Arr.NonEmptyReadonlyArray<string>, IE>
455 return Effect.suspend(() => done ? Cause.done() : pull)
456 })
457 )
458
459/**
460 * Creates an SSE encoder channel for values accepted by a schema.

Callers 5

encodeSchemaFunction · 0.70
SqlResolver.tsFile · 0.50
void_Function · 0.50
repeatedFieldFunction · 0.50
setFunction · 0.50

Calls 7

pipeMethod · 0.65
ofMethod · 0.65
writeMethod · 0.65
syncMethod · 0.45
mapMethod · 0.45
succeedMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected