ac5b9d3be81e3709ae2eaf37eeb6a762d879ed4e
[yaffs-website] / node_modules / grunt-legacy-util / node_modules / lodash / _copyObjectWith.js
1 var assignValue = require('./_assignValue');
2
3 /**
4  * This function is like `copyObject` except that it accepts a function to
5  * customize copied values.
6  *
7  * @private
8  * @param {Object} source The object to copy properties from.
9  * @param {Array} props The property names to copy.
10  * @param {Object} [object={}] The object to copy properties to.
11  * @param {Function} [customizer] The function to customize copied values.
12  * @returns {Object} Returns `object`.
13  */
14 function copyObjectWith(source, props, object, customizer) {
15   object || (object = {});
16
17   var index = -1,
18       length = props.length;
19
20   while (++index < length) {
21     var key = props[index],
22         newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
23
24     assignValue(object, key, newValue);
25   }
26   return object;
27 }
28
29 module.exports = copyObjectWith;