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

    Function difference

    • Reduces collections to their set difference.

      Keeps each element of the first collection absent from every other collection, once, in the order it first appears, so a base list is narrowed by any number of exclusion lists without duplicates. Without a comparator, elements are compared by identity the way a Set does (SameValueZero); pass equal to subtract by a custom relation instead. Given no collections, the result is empty; given a single collection, the result holds its distinct elements.

      Type Parameters

      • T

        The element type of the collections

      Parameters

      • values: Iterable<Many<T>>

        The collections to subtract: the first supplies the candidate elements, the others the elements to remove; 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 of the first collection missing from all the others, in the order they first appear in that collection