• Only emit values of an Iterable that have not been emitted yet.

    The values are by default compared by identity (===). An optional Mapper function can be used to map the values to a different representation for the comparison.

    Example

    Distinct by value

    const distinctByValue = distinct();
    const distinctValues = distinctByValue([1,2,1,3]);
    console.log(distinctValues); // [1,2,3]

    Example

    Distinct by keyMapper Function

    const distinctByValue = distinct(isEven);
    const distinctValues = distinctByValue([1,2,1,3]);
    console.log(distinctValues); // [1,2]

    See

    filter for similar operations.

    Returns

    an Iterable containing only unique values

    Type Parameters

    • T

      the Iterable value type

    Parameters

    • Optional keyMapper: Mapper<T, unknown>

      a Function that maps an element into a key

    Returns ((iterable: Iterable<T>) => IterableIterator<T>)

Generated using TypeDoc