Prelude API
    Preparing search index...

    Function unique

    • Creates a generator that yields unique values from the source iterable based on keys generated by the provided function.

      Type Parameters

      • T

        The type of elements in the source iterable.

      Parameters

      • keyOfValue: (value: T, index: number) => string | number

        Function that generates a string or number key for each element and its index.

      Returns (values: Iterable<T>) => Generator<T>

      A generator function that takes an iterable and yields unique elements.

      Unique elements from the source iterable, where uniqueness is determined by the key function.

      G.pipe(
      [1, 2, 2, 3, 4, 4, 5],
      G.unique(x => x),
      G.array
      ) // [1, 2, 3, 4, 5]

      G.pipe(
      [{id: 1, name: 'A'}, {id: 2, name: 'B'}, {id: 1, name: 'C'}],
      G.unique(x => x.id),
      G.array
      ) // [{id: 1, name: 'A'}, {id: 2, name: 'B'}]