mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Bump to v4.1.0.
This commit is contained in:
34
_createAssigner.js
Normal file
34
_createAssigner.js
Normal file
@@ -0,0 +1,34 @@
|
||||
var isIterateeCall = require('./_isIterateeCall'),
|
||||
rest = require('./rest');
|
||||
|
||||
/**
|
||||
* 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 rest(function(object, sources) {
|
||||
var index = -1,
|
||||
length = sources.length,
|
||||
customizer = length > 1 ? sources[length - 1] : undefined,
|
||||
guard = length > 2 ? sources[2] : undefined;
|
||||
|
||||
customizer = 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;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = createAssigner;
|
||||
Reference in New Issue
Block a user