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

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.

### Example

```ts
// Mutable array narrows to NonEmptyArray
const arr: Array<number> = [1, 2, 3];
if (isNonEmptyArray(arr)) {
  shiftFromArray(arr); // arr is NonEmptyArray<number>
}

// Readonly array narrows to NonEmptyReadonlyArray
const readonly: ReadonlyArray<number> = [1, 2, 3];
if (isNonEmptyArray(readonly)) {
  firstInArray(readonly); // readonly is NonEmptyReadonlyArray<number>
}
```

## Call Signature

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

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

Readonly array overload.