country-codes-list
Version:
List of codes per country (languages, calling codes, currency codes, etc) with full TypeScript support.
8 lines (7 loc) • 366 B
TypeScript
/**
* Groups an array by a specified key.
* @param array - The array to group.
* @param key - The key to group the array by.
* @returns An object where each key is a unique value from the array, and each value is an array of items from the original array that match the key.
*/
export default function groupBy<T>(array: T[], key: keyof T): Record<string, T[]>;