Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / createObjectMapper.js
1 var baseCallback = require('./baseCallback'),
2     baseForOwn = require('./baseForOwn');
3
4 /**
5  * Creates a function for `_.mapKeys` or `_.mapValues`.
6  *
7  * @private
8  * @param {boolean} [isMapKeys] Specify mapping keys instead of values.
9  * @returns {Function} Returns the new map function.
10  */
11 function createObjectMapper(isMapKeys) {
12   return function(object, iteratee, thisArg) {
13     var result = {};
14     iteratee = baseCallback(iteratee, thisArg, 3);
15
16     baseForOwn(object, function(value, key, object) {
17       var mapped = iteratee(value, key, object);
18       key = isMapKeys ? mapped : key;
19       value = isMapKeys ? value : mapped;
20       result[key] = value;
21     });
22     return result;
23   };
24 }
25
26 module.exports = createObjectMapper;