diff --git a/streams/concat_readable_streams.ts b/streams/concat_readable_streams.ts index 4ae98f266000..7eb94eff23ac 100644 --- a/streams/concat_readable_streams.ts +++ b/streams/concat_readable_streams.ts @@ -29,6 +29,10 @@ export function concatReadableStreams( ...streams: ReadableStream[] ): ReadableStream { + if (streams.length === 0) { + return ReadableStream.from([]); + } + let i = 0; return new ReadableStream({ async pull(controller) { diff --git a/streams/concat_readable_streams_test.ts b/streams/concat_readable_streams_test.ts index fb100ff1dd10..b0427404a933 100644 --- a/streams/concat_readable_streams_test.ts +++ b/streams/concat_readable_streams_test.ts @@ -26,6 +26,15 @@ Deno.test("concatStreams()", async () => { ); }); +Deno.test("concatStreams() with no streams", async () => { + assertEquals( + await Array.fromAsync( + concatReadableStreams(), + ), + [], + ); +}); + Deno.test("concatStreams() with empty streams", async () => { const readable1 = ReadableStream.from([]); const readable2 = ReadableStream.from([]);