• Returns an array of values from an iterator.

    const data = await toArray(adsrIterable(opts, 10));
    

    Note: If the iterator is infinite, be sure to provide limits via the options.

    // Return maximum five items
    const data = await toArray(iterable, { limit: 5 });
    // Return results for a maximum of 5 seconds
    const data = await toArray(iterable, { elapsed: 5000 });

    Note that limits are ORed, toArray will finish if either of them is true.

    Type Parameters

    • V

    Parameters

    • it: AsyncIterable<V>

      Asynchronous iterable

    • options: Partial<Iterables.ToArrayOptions> = {}

      Options when converting to array

    Returns Promise<V[]>