ts-data-forge
    Preparing search index...
    • Concatenates two arrays.

      The exact tuple shape is preserved. Additionally, when either input is known to be non-empty (a non-empty tuple or a branded NonEmptyArray), the result is branded as non-empty so it is assignable to NonEmptyArray.

      Type Parameters

      • const Ar1 extends readonly unknown[]
      • const Ar2 extends readonly unknown[]

      Parameters

      Returns ConcatResult<Ar1, Ar2>

      const numbers = [1, 2] as const;

      const words = ['three', 'four'] as const;

      const combined = Arr.concat(numbers, words);

      // Because at least one input is non-empty, the result is assignable to
      // NonEmptyArray.
      const nonEmpty: NonEmptyArray<number | string> = combined;

      const expectedCombined = [1, 2, 'three', 'four'] as const;

      assert.deepStrictEqual<readonly (number | string)[]>(
      combined,
      expectedCombined,
      );

      assert.isTrue(nonEmpty.length >= 1);