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

    Function intersection

    • Reduces collections to their set intersection.

      Keeps each element present in every one of the given collections, once, in the order it first appears in the first collection, so several sources narrow to the elements they share without duplicates. Without a comparator, elements are compared by identity the way a Set does (SameValueZero); pass equal to intersect by a custom relation instead. Given no collections, the result is empty.

      Type Parameters

      • T

        The element type of the collections

      Parameters

      • values: Iterable<Many<T>>

        The collections to intersect; each is drawn from at most once, so single-pass iterators are safe to pass

      • 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 element common to all of values, in the order they first appear in the first collection

      union for the dual, combining the elements of every collection