00001 var apply = require('./_apply');
00002
00003
00004 var nativeMax = Math.max;
00005
00015 function overRest(func, start, transform) {
00016 start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
00017 return function() {
00018 var args = arguments,
00019 index = -1,
00020 length = nativeMax(args.length - start, 0),
00021 array = Array(length);
00022
00023 while (++index < length) {
00024 array[index] = args[start + index];
00025 }
00026 index = -1;
00027 var otherArgs = Array(start + 1);
00028 while (++index < start) {
00029 otherArgs[index] = args[index];
00030 }
00031 otherArgs[start] = transform(array);
00032 return apply(func, this, otherArgs);
00033 };
00034 }
00035
00036 module.exports = overRest;