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

## Call Signature

```ts
function isNonEmptyArray<T>(array: T[]): array is [T, ...T[]];
```

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

Checks if an array is non-empty and narrows its type to [NonEmptyArray](https://evolu.dev/docs/api-reference/common/Array/type-aliases/NonEmptyArray)
or [NonEmptyReadonlyArray](https://evolu.dev/docs/api-reference/common/Array/type-aliases/NonEmptyReadonlyArray) based on the input.

To check if an array is empty, use `if (!isNonEmptyArray(arr))` — using the
negated guard is better than `.length === 0` for early returns because
TypeScript narrows the type after the check.

### Narrowing mutable and readonly arrays

```ts
import {
  assertEqual,
  assertType,
  firstInArray,
  isNonEmptyArray,
  type NonEmptyArray,
  type NonEmptyReadonlyArray,
} from "@evolu/common";

const mutable: Array<number> = [1, 2, 3];
const readonly: ReadonlyArray<number> = [1, 2, 3];
if (!isNonEmptyArray(mutable) || !isNonEmptyArray(readonly)) {
  throw new Error("Expected values");
}

assertType<NonEmptyArray<number>, typeof mutable>();
assertType<NonEmptyReadonlyArray<number>, typeof readonly>();
assertEqual(firstInArray(readonly), 1);
```

## Call Signature

```ts
function isNonEmptyArray<T>(array: readonly T[]): array is readonly [T, T];
```

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

Readonly array overload.