Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Grouper<T, V>

Grouper utility class, contains static factories for creating Grouper functions used with groupBy

author

Degubi

Type parameters

  • T

  • V

Hierarchy

  • Grouper

Index

Constructors

Properties

Methods

Constructors

Private constructor

  • new Grouper<T, V>(): Grouper<T, V>

Properties

Private _

_: undefined

Methods

Static averaging

  • averaging<T>(keySelectorFunction: (element: T) => number): Grouper<T, number>
  • Creates a grouper function that maps each key to the average of the keySelector's key

    Type parameters

    • T

    Parameters

    • keySelectorFunction: (element: T) => number

      Function used for extracting the property to calculate the average of

        • (element: T): number
        • Parameters

          • element: T

          Returns number

    Returns Grouper<T, number>

    A new grouper instance

Static counting

  • counting<T>(): Grouper<T, number>
  • Creates a grouper function that maps each key to 1 and then sums it (a.k.a counts the occurence of it) Useful for creating frequency maps

    Type parameters

    • T

    Returns Grouper<T, number>

    A new grouper instance

Static statisticizing

  • Creates a grouper function that maps each key to the statistics of the keySelector's key

    Type parameters

    • T

    Parameters

    • keySelectorFunction: (element: T) => number

      Function used for extracting the property to calculate the statistics of

        • (element: T): number
        • Parameters

          • element: T

          Returns number

    Returns Grouper<T, NumberStatistics>

    A new grouper instance

Static summing

  • summing<T>(keySelectorFunction: (element: T) => number): Grouper<T, number>
  • Creates a grouper function that maps each key to the sum of the keySelector's key

    Type parameters

    • T

    Parameters

    • keySelectorFunction: (element: T) => number

      Function used for extracting the property to calculate the sum of

        • (element: T): number
        • Parameters

          • element: T

          Returns number

    Returns Grouper<T, number>

    A new grouper instance

Static toArray

  • Creates a grouper function that maps each key to an array of elements for that specific key

    Type parameters

    • T

    Returns Grouper<T, T[]>

    A new grouper instance

Generated using TypeDoc