Type Parameters

  • T

Constructors

Properties

Methods

Constructors

Properties

array: T[]

Methods

  • The filter function takes an array and a predicate function, and returns a new array containing only the elements that satisfy the predicate.

    Type Parameters

    • T

    Parameters

    • arr: T[]

      The arr parameter is an array of elements of type T.

    • predicate: ((item) => boolean)

      The predicate parameter in the filter function is a callback function that takes an item of type T as its argument and returns a boolean value. This function is used to determine whether an item should be included in the resulting array based on the specified condition.

        • (item): boolean
        • Parameters

          • item: T

          Returns boolean

    Returns T[]

    The filter method is returning an array of elements that satisfy the given predicate function.

  • The groupBy function in TypeScript takes an array of items and groups them based on a specified key function.

    Type Parameters

    • T

    Parameters

    • arr: T[]

      The arr parameter is an array of elements of type T that you want to group based on a specific key.

    • keyFn: ((item) => string)

      The keyFn parameter is a function that takes an item of type T as input and returns a string. This function is used to determine the key for grouping the items in the array arr.

        • (item): string
        • Parameters

          • item: T

          Returns string

    Returns {
        [key: string]: T[];
    }

    The groupBy function returns an object where the keys are strings and the values are arrays of type T.

    • [key: string]: T[]

Generated using TypeDoc