ixfx
    Preparing search index...

    Function frequencyByGroup

    • Computes the frequency of values by a grouping function.

      const data = [1,2,3,4,5,6,7,8,9,10];
      // Returns 'odd' or 'even' for an input value

      const groupBy = v => v % 2 === 0 ? `even`:`odd`;

      const data = frequencyByGroup(groupBy, data);
      // Yields map with:
      // key: 'even', value: 5
      // key: 'odd', value: 5
      @param groupBy
      @param data
      @

      Type Parameters

      • TValue
      • TGroup extends string | number

      Parameters

      Returns Map<TGroup, number>