Function setUnion

  • Computes the union of multiple sets.

    Type Parameters

    • T

    Parameters

    • sets: Set<T>[]

      An array of sets to compute the union of.

    Returns Set<T>

    A new set that is the union of all sets in the input array.

    Remarks

    This function does not mutate the original sets.

    Typeparam

    T - The type of elements in the sets.

    Example

    const set1 = new Set([1, 2, 3]);
    const set2 = new Set([2, 3, 4]);
    const set3 = new Set([3, 4, 5]);
    setUnion([set1, set2, set3]);
    //=> Set(5) { 1, 2, 3, 4, 5 }

Generated using TypeDoc