[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:180](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Array.ts#L180)

Better `Array.from`.

- Returns readonly arrays
- Accepts length directly: `arrayFrom(3, fn)` instead of `Array.from({ length:
3 }, fn)`
- Skips copying if iterable is already an array (safe because readonly)

### Example

```ts
arrayFrom(new Set([1, 2, 3])); // ReadonlyArray<number>
arrayFrom(3, (i) => i * 10); // [0, 10, 20]
arrayFrom(iterableMaybeArray); // no unnecessary copy
```

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:182](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Array.ts#L182)

From length and map function.