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

    Function intersection

    • Reduces arrays to their set intersection.

      Keeps each element present in every one of the given arrays, once, in the order it first appears in the first array, 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 arrays, the result is empty.

      Type Parameters

      • T

        The element type of the arrays

      Parameters

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

        The arrays to intersect

      • 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 arrays, in the order they first appear in the first array

      union for the dual, combining the elements of every array