@mirei/ts-collections
    Preparing search index...

    Function distinct

    • Eliminates duplicate elements from the sequence using an optional comparator.

      Type Parameters

      • TElement

        Type of elements within the source iterable.

      Parameters

      • source: Iterable<TElement>

        The source iterable.

      • OptionalkeyComparator: EqualityComparator<TElement, TElement>

        Optional equality comparator used to determine whether two elements are identical. Defaults to the library's standard equality comparison.

      Returns IEnumerable<TElement>

      A sequence that yields each distinct element once.

      Elements are compared by value; provide a comparator for custom reference types.

      const numbers = [1, 2, 2, 3, 1, 4, 5, 5];
      const distinctNumbers = distinct(numbers).toArray();
      console.log(distinctNumbers); // [1, 2, 3, 4, 5]