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

## Call Signature

```ts
function mapArray<T, U>(
  array: readonly [T, T] | [T, ...T[]],
  mapper: (item: T, index: number) => U,
): readonly [U, U];
```

Defined in: [packages/common/src/Array.ts:312](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Array.ts#L312)

Maps an array using a mapper function, returning a new readonly array.

Preserves non-empty type.

### Example

```ts
mapArray([1, 2, 3], (x) => x * 2); // [2, 4, 6]
```

## Call Signature

```ts
function mapArray<T, U>(
  array: readonly T[] | T[],
  mapper: (item: T, index: number) => U,
): readonly U[];
```

Defined in: [packages/common/src/Array.ts:317](https://github.com/evoluhq/evolu/blob/e7144e2bbe9069362b62dec1b64a8aa922b8f1b0/packages/common/src/Array.ts#L317)

Possibly empty array.