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

    Function unique

    • Retains the unique values of a collection.

      Keeps the first occurrence of each value, dropping later duplicates. Without a comparator, values are deduplicated by identity the way a Set does (SameValueZero, so NaN collapses and -0 equals +0) in a single pass; pass equal to compare by a custom relation instead, at the cost of a scan over the earlier values for each value.

      Type Parameters

      • T

        The type of the contained values

      Parameters

      • values: Iterable<T>

        The values to deduplicate; drawn from exactly once, so single-pass iterators are safe to pass

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

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

      Returns readonly T[]

      A new array holding the first occurrence of each unique value from values, preserving their original order