MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / createStreamedResponse

Function createStreamedResponse

src/utils/zipDownload.test.ts:9–23  ·  view source on GitHub ↗
(chunks: number[][], contentLength?: number)

Source from the content-addressed store, hash-verified

7} from './zipDownload';
8
9function createStreamedResponse(chunks: number[][], contentLength?: number): Response {
10 return new Response(new ReadableStream<Uint8Array>({
11 start(controller) {
12 for (const chunk of chunks) {
13 controller.enqueue(new Uint8Array(chunk));
14 }
15 controller.close();
16 },
17 }), {
18 status: 200,
19 headers: contentLength === undefined ? undefined : {
20 'content-length': String(contentLength),
21 },
22 });
23}
24
25describe('zip download', () => {
26 it('streams archive downloads with bounded progress and concatenates chunks', async () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected