mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
/**
|
|
* lodash 3.0.1 (Custom Build) <https://lodash.com/>
|
|
* Build: `lodash modern modularize exports="npm" -o ./`
|
|
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
|
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
|
|
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
* Available under MIT license <https://lodash.com/license>
|
|
*/
|
|
var baseCopy = require('lodash._basecopy'),
|
|
keys = require('lodash.keys');
|
|
|
|
/**
|
|
* The base implementation of `_.assign` without support for argument juggling,
|
|
* multiple sources, and `this` binding `customizer` functions.
|
|
*
|
|
* @private
|
|
* @param {Object} object The destination object.
|
|
* @param {Object} source The source object.
|
|
* @param {Function} [customizer] The function to customize assigning values.
|
|
* @returns {Object} Returns the destination object.
|
|
*/
|
|
function baseAssign(object, source, customizer) {
|
|
var props = keys(source);
|
|
if (!customizer) {
|
|
return baseCopy(source, object, props);
|
|
}
|
|
var index = -1,
|
|
length = props.length;
|
|
|
|
while (++index < length) {
|
|
var key = props[index],
|
|
value = object[key],
|
|
result = customizer(value, source[key], key, object, source);
|
|
|
|
if ((result === result ? result !== value : value === value) ||
|
|
(typeof value == 'undefined' && !(key in object))) {
|
|
object[key] = result;
|
|
}
|
|
}
|
|
return object;
|
|
}
|
|
|
|
module.exports = baseAssign;
|