API reference@evolu/commonArray › arrayFromAsync

function arrayFromAsync<T>(
  iterable: AsyncIterable<T, any, any> | Iterable<T | PromiseLike<T>, any, any>,
): Promise<readonly T[]>;

Defined in: packages/common/src/Array.ts:225

Better Array.fromAsync.

Returns a readonly array and awaits promised items from sync or async iterables.

Example

await arrayFromAsync(new Set([1, 2, 3])); // ReadonlyArray<number>
await arrayFromAsync(
  (async function* () {
    yield Promise.resolve(1);
    yield Promise.resolve(2);
  })(),
); // [1, 2]

Unlike Array.fromAsync, there's no map parameter — map the result with mapArray or use iterator helpers directly on iterables.