CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
mapValues.js44 linesDownload Raw Back to lodash
1var baseAssignValue = require('./_baseAssignValue'),2    baseForOwn = require('./_baseForOwn'),3    baseIteratee = require('./_baseIteratee');4 5/**6 * Creates an object with the same keys as `object` and values generated7 * by running each own enumerable string keyed property of `object` thru8 * `iteratee`. The iteratee is invoked with three arguments:9 * (value, key, object).10 *11 * @static12 * @memberOf _13 * @since 2.4.014 * @category Object15 * @param {Object} object The object to iterate over.16 * @param {Function} [iteratee=_.identity] The function invoked per iteration.17 * @returns {Object} Returns the new mapped object.18 * @see _.mapKeys19 * @example20 *21 * var users = {22 *   'fred':    { 'user': 'fred',    'age': 40 },23 *   'pebbles': { 'user': 'pebbles', 'age': 1 }24 * };25 *26 * _.mapValues(users, function(o) { return o.age; });27 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)28 *29 * // The `_.property` iteratee shorthand.30 * _.mapValues(users, 'age');31 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)32 */33function mapValues(object, iteratee) {34  var result = {};35  iteratee = baseIteratee(iteratee, 3);36 37  baseForOwn(object, function(value, key, object) {38    baseAssignValue(result, key, iteratee(value, key, object));39  });40  return result;41}42 43module.exports = mapValues;44 
basant307/AI_Governance_Project · CoolFace