Function isNonEmptyArray

Determines if an array is not empty.

The type inferred for the array is ReadonlyArray<T>, but the type returned is NonEmptyArray<T>.

isNonEmptyArray([1, 2, 3]); // => true
isNonEmptyArray([]); // => false
  • Type Parameters

    • T

      The type of the items in the array to check.

    Parameters

    • x: readonly T[]

      The array to check.

    Returns x is NonEmptyArray<T>

    True if the array is not empty, false otherwise.