1 var bindCallback = require('./bindCallback'),
2 isIterateeCall = require('./isIterateeCall'),
3 restParam = require('../function/restParam');
6 * Creates a `_.assign`, `_.defaults`, or `_.merge` function.
9 * @param {Function} assigner The function to assign values.
10 * @returns {Function} Returns the new assigner function.
12 function createAssigner(assigner) {
13 return restParam(function(object, sources) {
15 length = object == null ? 0 : sources.length,
16 customizer = length > 2 ? sources[length - 2] : undefined,
17 guard = length > 2 ? sources[2] : undefined,
18 thisArg = length > 1 ? sources[length - 1] : undefined;
20 if (typeof customizer == 'function') {
21 customizer = bindCallback(customizer, thisArg, 5);
24 customizer = typeof thisArg == 'function' ? thisArg : undefined;
25 length -= (customizer ? 1 : 0);
27 if (guard && isIterateeCall(sources[0], sources[1], guard)) {
28 customizer = length < 3 ? undefined : customizer;
31 while (++index < length) {
32 var source = sources[index];
34 assigner(object, source, customizer);
41 module.exports = createAssigner;