CoolFace
Datasetpublic

basant307/AI_Governance_Project

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