@jossmac/lil-libs
    Preparing search index...

    Function isPopulatedArray

    • Type guard that narrows an array to a non-empty tuple-like type.

      • T
      • items: Maybe<T[] | readonly T[]>

        Array to test. null and undefined are treated as empty.

      true when items is non-null and has at least one element; narrows the type to a non-empty tuple.

      const values: number[] = [1, 2, 3];
      if (isPopulatedArray(values)) {
      // values: [number, ...number[]]
      }
      isPopulatedArray([]); // false
      isPopulatedArray(null); // false