Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / object / mapValues.js
1 var createObjectMapper = require('../internal/createObjectMapper');
2
3 /**
4  * Creates an object with the same keys as `object` and values generated by
5  * running each own enumerable property of `object` through `iteratee`. The
6  * iteratee function is bound to `thisArg` and invoked with three arguments:
7  * (value, key, object).
8  *
9  * If a property name is provided for `iteratee` the created `_.property`
10  * style callback returns the property value of the given element.
11  *
12  * If a value is also provided for `thisArg` the created `_.matchesProperty`
13  * style callback returns `true` for elements that have a matching property
14  * value, else `false`.
15  *
16  * If an object is provided for `iteratee` the created `_.matches` style
17  * callback returns `true` for elements that have the properties of the given
18  * object, else `false`.
19  *
20  * @static
21  * @memberOf _
22  * @category Object
23  * @param {Object} object The object to iterate over.
24  * @param {Function|Object|string} [iteratee=_.identity] The function invoked
25  *  per iteration.
26  * @param {*} [thisArg] The `this` binding of `iteratee`.
27  * @returns {Object} Returns the new mapped object.
28  * @example
29  *
30  * _.mapValues({ 'a': 1, 'b': 2 }, function(n) {
31  *   return n * 3;
32  * });
33  * // => { 'a': 3, 'b': 6 }
34  *
35  * var users = {
36  *   'fred':    { 'user': 'fred',    'age': 40 },
37  *   'pebbles': { 'user': 'pebbles', 'age': 1 }
38  * };
39  *
40  * // using the `_.property` callback shorthand
41  * _.mapValues(users, 'age');
42  * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
43  */
44 var mapValues = createObjectMapper();
45
46 module.exports = mapValues;