mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 01:17:50 +00:00
Bump to v3.7.0.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
var bindCallback = require('./bindCallback'),
|
||||
isIterateeCall = require('./isIterateeCall');
|
||||
isIterateeCall = require('./isIterateeCall'),
|
||||
restParam = require('../function/restParam');
|
||||
|
||||
/**
|
||||
* Creates a function that assigns properties of source object(s) to a given
|
||||
@@ -12,38 +13,32 @@ var bindCallback = require('./bindCallback'),
|
||||
* @returns {Function} Returns the new assigner function.
|
||||
*/
|
||||
function createAssigner(assigner) {
|
||||
return function() {
|
||||
var args = arguments,
|
||||
length = args.length,
|
||||
object = args[0];
|
||||
return restParam(function(object, sources) {
|
||||
var index = -1,
|
||||
length = object == null ? 0 : sources.length,
|
||||
customizer = length > 2 && sources[length - 2],
|
||||
guard = length > 2 && sources[2],
|
||||
thisArg = length > 1 && sources[length - 1];
|
||||
|
||||
if (length < 2 || object == null) {
|
||||
return object;
|
||||
}
|
||||
var customizer = args[length - 2],
|
||||
thisArg = args[length - 1],
|
||||
guard = args[3];
|
||||
|
||||
if (length > 3 && typeof customizer == 'function') {
|
||||
if (typeof customizer == 'function') {
|
||||
customizer = bindCallback(customizer, thisArg, 5);
|
||||
length -= 2;
|
||||
} else {
|
||||
customizer = (length > 2 && typeof thisArg == 'function') ? thisArg : null;
|
||||
customizer = typeof thisArg == 'function' ? thisArg : null;
|
||||
length -= (customizer ? 1 : 0);
|
||||
}
|
||||
if (guard && isIterateeCall(args[1], args[2], guard)) {
|
||||
customizer = length == 3 ? null : customizer;
|
||||
length = 2;
|
||||
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||
customizer = length < 3 ? null : customizer;
|
||||
length = 1;
|
||||
}
|
||||
var index = 0;
|
||||
while (++index < length) {
|
||||
var source = args[index];
|
||||
var source = sources[index];
|
||||
if (source) {
|
||||
assigner(object, source, customizer);
|
||||
}
|
||||
}
|
||||
return object;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = createAssigner;
|
||||
|
||||
Reference in New Issue
Block a user