[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) › arrayFrom

## Call Signature

```ts
function arrayFrom<T>(iterable: Iterable<T>): readonly T[];
```

Defined in: [packages/common/src/Array.ts:259](https://github.com/evoluhq/evolu/blob/037c390af081e9944d616ff298a729515c5c5ab7/packages/common/src/Array.ts#L259)

Better `Array.from`.

- Returns readonly arrays
- Accepts length directly: `arrayFrom(3, fn)` instead of `Array.from({ length:
3 }, fn)`
- Returns existing arrays unchanged

### Creating from iterables and lengths

```ts

const fromSet = arrayFrom(new Set([1, 2, 3]));
assertEqual(fromSet, [1, 2, 3]);
assertType<ReadonlyArray<number>, typeof fromSet>();

assertEqual(
  arrayFrom(3, (i) => i * 10),
  [0, 10, 20],
);

const existing: ReadonlyArray<number> = [1, 2, 3];
assertSame(arrayFrom(existing), existing);
```

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

## Call Signature

```ts
function arrayFrom<T>(length: number, map: (index: number) => T): readonly T[];
```

Defined in: [packages/common/src/Array.ts:261](https://github.com/evoluhq/evolu/blob/037c390af081e9944d616ff298a729515c5c5ab7/packages/common/src/Array.ts#L261)

From length and map function.