Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions streams/concat_readable_streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
export function concatReadableStreams<T>(
...streams: ReadableStream<T>[]
): ReadableStream<T> {
if (streams.length === 0) {
return ReadableStream.from([]);
}

let i = 0;
return new ReadableStream<T>({
async pull(controller) {
Expand Down
9 changes: 9 additions & 0 deletions streams/concat_readable_streams_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
Expand Down
Loading