diff --git a/async/chain.ts b/async/chain.ts index 443ca7f..362e477 100644 --- a/async/chain.ts +++ b/async/chain.ts @@ -14,7 +14,7 @@ * ``` */ export async function* chain( - ...iterables: Iterable[] | AsyncIterable[] + ...iterables: (Iterable | AsyncIterable)[] ): AsyncIterable { for await (const iterable of iterables) { for await (const value of iterable) { diff --git a/async/chain_test.ts b/async/chain_test.ts index df7393b..898baa7 100644 --- a/async/chain_test.ts +++ b/async/chain_test.ts @@ -22,4 +22,15 @@ Deno.test("chain", async (t) => { assertEquals(await toArray(result), expected); assertType>>(true); }); + + await t.step("with mixed iterable", async () => { + const result = chain( + toAsyncIterable([1, 2]), + [3, 4], + toAsyncIterable([5]), + ); + const expected = [1, 2, 3, 4, 5]; + assertEquals(await toArray(result), expected); + assertType>>(true); + }); });