ts-data-forge
    Preparing search index...
    • Computes the union of two ISet instances.

      Returns a new set containing all elements that are present in either input set. Duplicate elements are automatically handled since sets only contain unique values. This operation is commutative: union(a, b) === union(b, a).

      Performance: O(n + m) where n and m are the sizes of the input sets.

      Type Parameters

      • K1 extends Primitive

        The type of elements in the first set.

      • K2 extends Primitive

        The type of elements in the second set.

      Parameters

      Returns ISet<K1 | K2>

      A new ISet instance containing all elements from both sets.

      const numbers = ISet.create([1, 2]);
      const words = ISet.create(['one', 'two']);

      const union = ISet.union(numbers, words);

      assert.deepStrictEqual(Array.from(union), [1, 2, 'one', 'two']);