Function distinctBy

  • Returns a Stream that yields distinct elements from the source based on the equals function.

    Type Parameters

    • T

      Type of items in the source.

    Parameters

    Returns OperationFunction<T, T>

    Operation that yields distinct elements from the source.

    const result = distinctBy<number>((a, b) => a % 2 === b % 2)([1, 2, 1, 3, 2, 4]);
    console.log([...result]); // [1, 2]