| 788 | } |
| 789 | |
| 790 | const feed = ( |
| 791 | chunk: Arr.NonEmptyReadonlyArray<Uint8Array<ArrayBuffer>> |
| 792 | ): Pull.Pull<Arr.NonEmptyReadonlyArray<S["Type"]>, Schema.SchemaError | IE, Done> => { |
| 793 | const raw: Array<unknown> = [] |
| 794 | try { |
| 795 | for (let i = 0; i < chunk.length; i++) { |
| 796 | const values = frames.feedSync(chunk[i]) |
| 797 | for (let j = 0; j < values.length; j++) raw.push(values[j]) |
| 798 | } |
| 799 | } catch (e) { |
| 800 | if (!Schema.isSchemaError(e)) return Effect.die(e) |
| 801 | if (raw.length === 0) return Effect.fail(e) |
| 802 | // Emit the values framed before the failure, then fail on the next |
| 803 | // pull. |
| 804 | stashed = e |
| 805 | } |
| 806 | if (!Arr.isReadonlyArrayNonEmpty(raw)) return pull |
| 807 | return decodeEncoded === undefined |
| 808 | ? Effect.succeed(raw as Arr.NonEmptyReadonlyArray<S["Type"]>) |
| 809 | : decodeAll(raw) |
| 810 | } |
| 811 | |
| 812 | const pull: Pull.Pull<Arr.NonEmptyReadonlyArray<S["Type"]>, Schema.SchemaError | IE, Done> = Effect.suspend(() => |
| 813 | stashed !== undefined ? Effect.fail(stashed) : Pull.matchEffect(upstream, { |