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

Function decodeAll

packages/effect/src/encoding/SchemaBinary.ts:768–788  ·  view source on GitHub ↗
(
        raw: ReadonlyArray<unknown>
      )

Source from the content-addressed store, hash-verified

766 // Decodes framed values in order. On a failure, values decoded before it
767 // are emitted first and the error fails the next pull.
768 const decodeAll = (
769 raw: ReadonlyArray<unknown>
770 ): Pull.Pull<Arr.NonEmptyReadonlyArray<S["Type"]>, Schema.SchemaError | IE, Done> => {
771 const out: Array<S["Type"]> = []
772 const loop: Effect.Effect<Arr.NonEmptyReadonlyArray<S["Type"]>, Schema.SchemaError> = Effect.suspend(() =>
773 out.length === raw.length
774 ? Effect.succeed(out as unknown as Arr.NonEmptyReadonlyArray<S["Type"]>)
775 : Effect.flatMap(decodeEncoded!(raw[out.length]), (value) => {
776 out.push(value as S["Type"])
777 return loop
778 })
779 )
780 return Effect.catch(loop, (error) => {
781 if (out.length === 0) {
782 stashed = undefined
783 return Effect.fail(error)
784 }
785 stashed = error
786 return Effect.succeed(out as unknown as Arr.NonEmptyReadonlyArray<S["Type"]>)
787 })
788 }
789
790 const feed = (
791 chunk: Arr.NonEmptyReadonlyArray<Uint8Array<ArrayBuffer>>

Callers 1

feedFunction · 0.85

Calls 3

pushMethod · 0.65
failMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected