Rename private spread helper to flatSpread.

This commit is contained in:
John-David Dalton
2016-11-16 20:05:15 -08:00
parent 5cb80a0a84
commit eba18891e5

View File

@@ -65,23 +65,24 @@ function createCloner(func) {
} }
/** /**
* This function is like `_.spread` except that it includes arguments after those spread. * A specialized version of `_.spread` which flattens the spread array into
* the arguments of the invoked `func`.
* *
* @private * @private
* @param {Function} func The function to spread arguments over. * @param {Function} func The function to spread arguments over.
* @param {number} start The start position of the spread. * @param {number} start The start position of the spread.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new function.
*/ */
function spread(func, start) { function flatSpread(func, start) {
return function() { return function() {
var length = arguments.length, var length = arguments.length,
lastIndex = length - 1,
args = Array(length); args = Array(length);
while (length--) { while (length--) {
args[length] = arguments[length]; args[length] = arguments[length];
} }
var array = args[start], var array = args[start],
lastIndex = args.length - 1,
otherArgs = args.slice(0, start); otherArgs = args.slice(0, start);
if (array) { if (array) {
@@ -313,7 +314,7 @@ function baseConvert(util, name, func, options) {
var data = mapping.methodSpread[name], var data = mapping.methodSpread[name],
start = data && data.start; start = data && data.start;
return start === undefined ? ary(func, n) : spread(func, start); return start === undefined ? ary(func, n) : flatSpread(func, start);
} }
return func; return func;
} }
@@ -483,8 +484,8 @@ function baseConvert(util, name, func, options) {
each(aryMethodKeys, function(aryKey) { each(aryMethodKeys, function(aryKey) {
each(mapping.aryMethod[aryKey], function(otherName) { each(mapping.aryMethod[aryKey], function(otherName) {
if (realName == otherName) { if (realName == otherName) {
var spreadData = mapping.methodSpread[realName], var data = mapping.methodSpread[realName],
afterRearg = spreadData && spreadData.afterRearg; afterRearg = data && data.afterRearg;
result = afterRearg result = afterRearg
? castFixed(realName, castRearg(realName, wrapped, aryKey), aryKey) ? castFixed(realName, castRearg(realName, wrapped, aryKey), aryKey)