CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
mapKeys.d.mts31 linesDownload Raw Back to map
1/**2 * Creates a new Map with the same values but with keys transformed by the provided function.3 *4 * This function takes a Map and a function that generates a new key from each value-key pair.5 * It returns a new Map where the keys are the result of applying the function to each entry,6 * while the values remain the same.7 *8 * @template K - The type of keys in the Map.9 * @template V - The type of values in the Map.10 * @param {Map<K, V>} map - The Map to transform.11 * @param {(value: V, key: K, object: Map<K, V>) => K} getNewKey - A function that generates a new key from a value-key pair.12 * @returns {Map<K, V>} A new Map with transformed keys and the same values.13 *14 * @example15 * const map = new Map([16 *   ['a', 1],17 *   ['b', 2],18 *   ['c', 3]19 * ]);20 * const result = mapKeys(map, (value, key) => key.toUpperCase());21 * // result will be:22 * // Map(3) {23 * //   'A' => 1,24 * //   'B' => 2,25 * //   'C' => 326 * // }27 */28declare function mapKeys<K, V>(map: Map<K, V>, getNewKey: (value: V, key: K, object: Map<K, V>) => K): Map<K, V>;29 30export { mapKeys };31 
basant307/AI_Governance_Project · CoolFace