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

## Call Signature

```ts
function partitionArray<T, S>(
  array: readonly T[],
  refinement: RefinementWithIndex<T, S>,
): readonly [readonly S[], readonly Exclude<T, S>[]];
```

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

Partitions an array into two readonly arrays based on a predicate or
refinement function.

Returns a tuple where the first array contains elements that satisfy the
predicate, and the second array contains elements that do not.

When used with a refinement function (with `value is Type` syntax),
TypeScript will narrow the first array to the narrowed type, making it useful
for filtering with Evolu Types like `PositiveInt.is`.

### Example

### With predicate

```ts
const [evens, odds] = partitionArray([1, 2, 3, 4, 5], (x) => x % 2 === 0);
evens; // [2, 4]
odds; // [1, 3, 5]
```

### With refinement

```ts
const mixed: ReadonlyArray<NonEmptyString | PositiveInt> = [
  NonEmptyString.orThrow("hello"),
  PositiveInt.orThrow(42),
];
const [positiveInts, strings] = partitionArray(mixed, PositiveInt.is);
// positiveInts: ReadonlyArray<PositiveInt> (narrowed type)
// strings: ReadonlyArray<NonEmptyString> (Exclude<T, PositiveInt>)
```

## Call Signature

```ts
function partitionArray<T>(
  array: readonly T[],
  predicate: PredicateWithIndex<T>,
): readonly [readonly T[], readonly T[]];
```

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

With predicate.