@mirei/ts-collections
    Preparing search index...

    Function multimode

    • Produces the elements whose occurrence count is tied for the highest frequency in source.

      Type Parameters

      • TElement

        Type of elements within the source iterable.

      • TKey

        Type of key produced by keySelector.

      Parameters

      • source: Iterable<TElement>

        The source iterable to inspect.

      • OptionalkeySelector: Selector<TElement, TKey>

        Optional selector that projects each element to the key used for frequency counting. Defaults to the element itself.

      Returns IEnumerable<TElement>

      A deferred sequence containing one representative element for each frequency mode.

      Re-throws any error thrown while iterating source or executing keySelector.

      Enumeration of the result buffers the entire source to compute frequency counts before yielding results. When multiple elements share a key, only the first occurrence is emitted.

      const modes = multimode([1, 2, 2, 3, 3]).toArray();
      console.log(modes); // [2, 3]