@metreeca/core - v0.9.22
    Preparing search index...

    Function union

    • Combines arrays into their set union.

      Flattens the given arrays and keeps each distinct element once, in first-seen order, so several sources combine into a single list without duplicates. Without a comparator, elements are compared by identity the way a Set does (SameValueZero) in a single pass; pass equal to merge by a custom relation instead, at the cost of a scan over the earlier elements for each element.

      Type Parameters

      • T

        The element type of the arrays

      Parameters

      • arrays: readonly (readonly T[])[]

        The arrays to combine

      • Optionalequal: (x: T, y: T) => boolean

        An optional custom equality function for comparing elements; without it, elements are compared by Set identity (SameValueZero)

      Returns readonly T[]

      A new array holding every distinct element drawn from arrays, in first-seen order

      intersection for the dual, keeping only the elements common to every array