Add start param to _.spread.

This commit is contained in:
John-David Dalton
2016-02-01 00:08:51 -08:00
parent fe5381b0f4
commit b38cf204f7

View File

@@ -9039,6 +9039,7 @@
* @memberOf _
* @category Function
* @param {Function} func The function to spread arguments over.
* @param {number} [start=0] The start position of the spread.
* @returns {Function} Returns the new function.
* @example
*
@@ -9059,13 +9060,20 @@
* }));
* // => a Promise of 76
*/
function spread(func) {
function spread(func, start) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function(array) {
return apply(func, this, array);
};
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
return rest(function(args) {
var array = args[start],
spreadArgs = args.slice(0, start);
if (array) {
arrayPush(spreadArgs, array);
}
return apply(func, this, spreadArgs);
});
}
/**