[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Array](https://evolu.dev/docs/api-reference/common/Array) › arrayFromAsync

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

Defined in: [packages/common/src/Array.ts:286](https://github.com/evoluhq/evolu/blob/ca15b4661c40fedb9f47434497086039cbdea38e/packages/common/src/Array.ts#L286)

Better `Array.fromAsync`.

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

### Awaiting sync and async iterables

```ts

const fromIterable = await arrayFromAsync(new Set([1, 2, 3]));
expect(fromIterable).toEqual([1, 2, 3]);

const fromAsyncIterable = await arrayFromAsync(
  (async function* () {
    yield Promise.resolve(1);
    yield Promise.resolve(2);
  })(),
);
expect(fromAsyncIterable).toEqual([1, 2]);
expectTypeOf(fromAsyncIterable).toEqualTypeOf<ReadonlyArray<number>>();
```

Unlike `Array.fromAsync`, there's no map parameter — map the result with
[mapArray](https://evolu.dev/docs/api-reference/common/Array/functions/mapArray) or use
[iterator helpers](https://web.dev/blog/baseline-iterator-helpers)
directly on iterables.