UNPKG

@alexaegis/common

Version:

Common utility functions

14 lines 688 B
/** * groups an array of elements into multiple arrays on an object where the * key is the string returned by the groupKey function. * * If the groupKey function returns undefined, the value won't be included * in the result. This can be used to filter out values from the initial array. * * There's also an ECMAScript proposal that will add a very similar function * on Object and Array: https://github.com/tc39/proposal-array-grouping * * This function can be deprecated once it's widely released. */ export declare const groupBy: <T, K extends string>(elements: T[], groupKey: (element: T) => K | undefined) => Record<K, T[]>; //# sourceMappingURL=group-by.function.d.ts.map