Skip to content

Commit e5c2055

Browse files
committed
fix: accept no streams in concatReadableStreams
1 parent cdf74a8 commit e5c2055

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

streams/concat_readable_streams.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
export function concatReadableStreams<T>(
3030
...streams: ReadableStream<T>[]
3131
): ReadableStream<T> {
32+
if (streams.length === 0) {
33+
return ReadableStream.from([]);
34+
}
35+
3236
let i = 0;
3337
return new ReadableStream<T>({
3438
async pull(controller) {

streams/concat_readable_streams_test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ Deno.test("concatStreams()", async () => {
2626
);
2727
});
2828

29+
Deno.test("concatStreams() with no streams", async () => {
30+
assertEquals(
31+
await Array.fromAsync(
32+
concatReadableStreams(),
33+
),
34+
[],
35+
);
36+
});
37+
2938
Deno.test("concatStreams() with empty streams", async () => {
3039
const readable1 = ReadableStream.from([]);
3140
const readable2 = ReadableStream.from([]);

0 commit comments

Comments
 (0)