mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
862 B
30 lines
862 B
9 years ago
|
var assignValue = require('./_assignValue');
|
||
|
|
||
|
/**
|
||
|
* This function is like `copyObject` except that it accepts a function to
|
||
|
* customize copied values.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Object} source The object to copy properties from.
|
||
|
* @param {Array} props The property names to copy.
|
||
|
* @param {Object} [object={}] The object to copy properties to.
|
||
|
* @param {Function} [customizer] The function to customize copied values.
|
||
|
* @returns {Object} Returns `object`.
|
||
|
*/
|
||
|
function copyObjectWith(source, props, object, customizer) {
|
||
|
object || (object = {});
|
||
|
|
||
|
var index = -1,
|
||
|
length = props.length;
|
||
|
|
||
|
while (++index < length) {
|
||
|
var key = props[index],
|
||
|
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
|
||
|
|
||
|
assignValue(object, key, newValue);
|
||
|
}
|
||
|
return object;
|
||
|
}
|
||
|
|
||
|
module.exports = copyObjectWith;
|