1 var apply = require('./_apply');
3 /* Built-in method references for those with the same name as other `lodash` methods. */
4 var nativeMax = Math.max;
7 * A specialized version of `baseRest` which transforms the rest array.
10 * @param {Function} func The function to apply a rest parameter to.
11 * @param {number} [start=func.length-1] The start position of the rest parameter.
12 * @param {Function} transform The rest array transform.
13 * @returns {Function} Returns the new function.
15 function overRest(func, start, transform) {
16 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
20 length = nativeMax(args.length - start, 0),
21 array = Array(length);
23 while (++index < length) {
24 array[index] = args[start + index];
27 var otherArgs = Array(start + 1);
28 while (++index < start) {
29 otherArgs[index] = args[index];
31 otherArgs[start] = transform(array);
32 return apply(func, this, otherArgs);
36 module.exports = overRest;