artdaq_node_server  v1_00_08
 All Classes Namespaces Files Variables Pages
spread.js
1 var apply = require('./_apply'),
2  arrayPush = require('./_arrayPush'),
3  baseRest = require('./_baseRest'),
4  castSlice = require('./_castSlice'),
5  toInteger = require('./toInteger');
6 
8 var FUNC_ERROR_TEXT = 'Expected a function';
9 
10 /* Built-in method references for those with the same name as other `lodash` methods. */
11 var nativeMax = Math.max;
12 
47 function spread(func, start) {
48  if (typeof func != 'function') {
49  throw new TypeError(FUNC_ERROR_TEXT);
50  }
51  start = start == null ? 0 : nativeMax(toInteger(start), 0);
52  return baseRest(function(args) {
53  var array = args[start],
54  otherArgs = castSlice(args, 0, start);
55 
56  if (array) {
57  arrayPush(otherArgs, array);
58  }
59  return apply(func, this, otherArgs);
60  });
61 }
62 
63 module.exports = spread;