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.
38 lines
1.0 KiB
38 lines
1.0 KiB
2 years ago
|
import baseRest from './_baseRest.js';
|
||
|
import isIterateeCall from './_isIterateeCall.js';
|
||
|
|
||
|
/**
|
||
|
* Creates a function like `_.assign`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {Function} assigner The function to assign values.
|
||
|
* @returns {Function} Returns the new assigner function.
|
||
|
*/
|
||
|
function createAssigner(assigner) {
|
||
|
return baseRest(function(object, sources) {
|
||
|
var index = -1,
|
||
|
length = sources.length,
|
||
|
customizer = length > 1 ? sources[length - 1] : undefined,
|
||
|
guard = length > 2 ? sources[2] : undefined;
|
||
|
|
||
|
customizer = (assigner.length > 3 && typeof customizer == 'function')
|
||
|
? (length--, customizer)
|
||
|
: undefined;
|
||
|
|
||
|
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||
|
customizer = length < 3 ? undefined : customizer;
|
||
|
length = 1;
|
||
|
}
|
||
|
object = Object(object);
|
||
|
while (++index < length) {
|
||
|
var source = sources[index];
|
||
|
if (source) {
|
||
|
assigner(object, source, index, customizer);
|
||
|
}
|
||
|
}
|
||
|
return object;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
export default createAssigner;
|