Function distinctUntilKeyChanged

  • Returns a Stream that yields elements from the source that are distinct from the previous element based on the key.

    Type Parameters

    • T

      Type of items in the source.

    • K extends string | number | symbol

    Parameters

    • key: K

      Key to compare elements.

    • OptionalequalsFunction: EqualsFunction<T[K]>

      Function to compare elements.

    Returns OperationFunction<T, T>

    const result = distinctUntilKeyChanged('a')([{ a: 1 }, { a: 1 }, { a: 2 }, { a: 2 }, { a: 3 }, { a: 3 }]);
    console.log([...result]); // [{ a: 1 }, { a: 2 }, { a: 3 }]