import { arrayFromIterable } from "https://deno.land/x/enzastdlib@v0.0.4/async/iterable.ts";
Returns all values collected from the iterable
in an array.
NOTE: This function is the equivilent of
Array.fromAsync
if it available in your runtime use that instead.
Examples
Example 1
Example 1
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts';
import { arrayFromIterable } from 'https://deno.land/x/enzastdlib/async/mod.ts';
async function* myGenerator(): AsyncGenerator<number> {
yield Promise.resolve(1);
yield Promise.resolve(2);
yield Promise.resolve(3);
}
const generator = myGenerator();
const numbers = await arrayFromIterable(generator);
assertEquals(numbers, [1, 2, 3]);
Parameters
iterable: AsyncIterable<Value>