ts-iterable-functions
    Preparing search index...

    Function _deduplicateBy

    • Removes duplicate elements from an iterable by the key produced by keySelector.

      Type Parameters

      • T

        Element type produced by the source iterable.

      • K

        Key type generated from each element.

      Parameters

      • src: Iterable<T>

        Source iterable that may contain duplicate keys.

      • keySelector: IndexedSelector<T, K>

        Selector receiving each element and its index, yielding the key used for distinctness.

      Returns Iterable<T>

      An iterable yielding the first element encountered for each distinct key.

      Error Propagates any error thrown by keySelector.

      const data = [
      { id: 1, value: "a" },
      { id: 1, value: "b" },
      { id: 2, value: "c" },
      ];

      const deduped = [..._deduplicateBy(data, ({ id }) => id)];
      // deduped === [data[0], data[2]]