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

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]));
expect(fromSet).toEqual([1, 2, 3]);
expectTypeOf(fromSet).toEqualTypeOf<ReadonlyArray<number>>();

expect(arrayFrom(3, (i) => i * 10)).toEqual([0, 10, 20]);

const existing: ReadonlyArray<number> = [1, 2, 3];
expect(arrayFrom(existing)).toBe(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:237](https://github.com/evoluhq/evolu/blob/ca15b4661c40fedb9f47434497086039cbdea38e/packages/common/src/Array.ts#L237)

From length and map function.