mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Add start param to _.spread.
This commit is contained in:
16
lodash.js
16
lodash.js
@@ -9039,6 +9039,7 @@
|
|||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Function
|
* @category Function
|
||||||
* @param {Function} func The function to spread arguments over.
|
* @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.
|
* @returns {Function} Returns the new function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -9059,13 +9060,20 @@
|
|||||||
* }));
|
* }));
|
||||||
* // => a Promise of 76
|
* // => a Promise of 76
|
||||||
*/
|
*/
|
||||||
function spread(func) {
|
function spread(func, start) {
|
||||||
if (typeof func != 'function') {
|
if (typeof func != 'function') {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
return function(array) {
|
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
|
||||||
return apply(func, this, array);
|
return rest(function(args) {
|
||||||
};
|
var array = args[start],
|
||||||
|
spreadArgs = args.slice(0, start);
|
||||||
|
|
||||||
|
if (array) {
|
||||||
|
arrayPush(spreadArgs, array);
|
||||||
|
}
|
||||||
|
return apply(func, this, spreadArgs);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user