artdaq_node_server  v1_00_07
 All Classes Namespaces Files Variables Pages
_overRest.js
1 var apply = require('./_apply');
2 
3 /* Built-in method references for those with the same name as other `lodash` methods. */
4 var nativeMax = Math.max;
5 
15 function overRest(func, start, transform) {
16  start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
17  return function() {
18  var args = arguments,
19  index = -1,
20  length = nativeMax(args.length - start, 0),
21  array = Array(length);
22 
23  while (++index < length) {
24  array[index] = args[start + index];
25  }
26  index = -1;
27  var otherArgs = Array(start + 1);
28  while (++index < start) {
29  otherArgs[index] = args[index];
30  }
31  otherArgs[start] = transform(array);
32  return apply(func, this, otherArgs);
33  };
34 }
35 
36 module.exports = overRest;