ts-data-forge
    Preparing search index...
    • Type guard that checks if an array is empty.

      Type Parameters

      • Xs extends readonly unknown[]

      Parameters

      • array: Xs

      Returns array is readonly Xs[number][] & Readonly<{ MaxLength: 0 }> & Readonly<
          {
              "TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3": unknown;
          },
      > & Readonly<{ MinLength: readonly 0[] }> & readonly [] & Xs

      const emptyNumbers: readonly number[] = [] as const;

      const words = ['Ada', 'Lovelace'] as const;

      assert.isTrue(Arr.isEmpty(emptyNumbers));

      assert.isFalse(Arr.isEmpty(words));

      if (Arr.isEmpty(emptyNumbers)) {
      // `isEmpty` narrows to the branded `FixedLengthArray<0, number>`, so the
      // expected value is annotated with the unbranded type.
      assert.deepStrictEqual<readonly number[]>(emptyNumbers, []);
      }