Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

UserGroup

UserGroup: {}

an type that is used to define the data structure when user models are grouped by a key

Type declaration

  • [K: string]: User[]

Functions

copyUserArray

  • copies the user array to allow sorting and manipulations to not effect any other groups

    Parameters

    Returns User[]

groupArrayBy

  • groupArrayBy<T>(items: T[], key: string): {}
  • Function used to group an array of objects into a an object with a value of user[]. Where the object's key represents that group ex: [{a:"apple"}, {}a:'orange'}, {a:"apple"}] => {"apple": [{a:"apple"}, {a:"apple"}], 'orange": [{a:"orange"}]}

    Type parameters

    • T

    Parameters

    • items: T[]

      items to be groups

    • key: string

      key by which to group them

    Returns {}

    • [K: string]: T[]

groupByAndSort

  • groupByAndSort<T>(arrayToGroup: T[], groupByKey: string, sortOptions: { innerSortOptions?: SortBy; outerSortOptions?: SortBy }): {}
  • This function sorts a given array, then groups it by a key, then sorts the inner group. Each sort is optional and if not given it will leave the array in the given order. outerSortOptions - is the sorting options preformed before the array is grouped. innerSortOptions - is the sort that is preformed after the array is grouped

    Type parameters

    • T

    Parameters

    • arrayToGroup: T[]

      the user model array to be grouped.

    • groupByKey: string

      is the key used to group the array by a specific key

    • sortOptions: { innerSortOptions?: SortBy; outerSortOptions?: SortBy }

      {outerSortOptions?: SortBy, innerSortOptions?: SortBy} - The sorting options

      • Optional innerSortOptions?: SortBy
      • Optional outerSortOptions?: SortBy

    Returns {}

    • [K: string]: T[]

groupsToArray

  • groupsToArray<T>(arrayToGroup: {}): T[]
  • Takes and object that represents users grouped by a key and turns it into an array. For example {Female: user[], Male: user[]} => user[]

    Type parameters

    • T

    Parameters

    • arrayToGroup: {}

      group to reduce to array

      • [key: string]: T[]

    Returns T[]

orderUsersAsExpected

  • orderUsersAsExpected(users: User[]): User[][]
  • the only function that would be exported if this were a package. This function takes an array of user models and outputs them into the expected order. It works by:

    1. makes a copy of the users for each of the 3 orderings
    2. preforms a sort, group-by, and inner group sort as given in the instructions

    Parameters

    • users: User[]

      users that are used to create the group and sorts

    Returns User[][]

    User[][] - a user array of arrays where each group is in its own individual array.

sortArrayBy

  • sortArrayBy<T>(arrayIn: T[], sortBy: SortBy): T[]
  • The function that is used for all sorting objects. It takes a key and a direction on which to sort with. It can be used on numbers, strings, and dates.

    Type parameters

    • T

    Parameters

    • arrayIn: T[]

      the array of objects in which to sort.

    • sortBy: SortBy

      the options used to preform the sort

    Returns T[]

sortItemsInGroup

  • sortItemsInGroup<T>(groups: {}, sortOptions: SortBy): void
  • The sorting function that is used to sort items in a group

    Type parameters

    • T

    Parameters

    • groups: {}

      the grouped items

      • [K: string]: T[]
    • sortOptions: SortBy

      the sort options used to sort the items in the group: key and ordering.

    Returns void

Generated using TypeDoc