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

    Function unique

    • Retains the unique values of an array.

      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 item.

      Type Parameters

      • T

        The type of the array items

      Parameters

      • values: readonly T[]

        The array to reduce to its unique values

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

        An optional custom equality function for comparing items; without it, items 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