(chunks: Uint8Array[])
| 17 | } from '@/lib/core/utils/stream-limits' |
| 18 | |
| 19 | function streamFromChunks(chunks: Uint8Array[]): ReadableStream<Uint8Array> { |
| 20 | let index = 0 |
| 21 | return new ReadableStream({ |
| 22 | pull(controller) { |
| 23 | if (index >= chunks.length) { |
| 24 | controller.close() |
| 25 | return |
| 26 | } |
| 27 | controller.enqueue(chunks[index]) |
| 28 | index += 1 |
| 29 | }, |
| 30 | }) |
| 31 | } |
| 32 | |
| 33 | function headers(contentLength?: string): Headers { |
| 34 | const headers = new Headers() |