PHP 8.2.30
Preview: restParam.js Size: 1.85 KB
/opt/alt/alt-nodejs9/root/lib/node_modules/npm/node_modules/cli-table2/node_modules/lodash/function/restParam.js

/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';

/* Native method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;

/**
 * Creates a function that invokes `func` with the `this` binding of the
 * created function and arguments from `start` and beyond provided as an array.
 *
 * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters).
 *
 * @static
 * @memberOf _
 * @category Function
 * @param {Function} func The function to apply a rest parameter to.
 * @param {number} [start=func.length-1] The start position of the rest parameter.
 * @returns {Function} Returns the new function.
 * @example
 *
 * var say = _.restParam(function(what, names) {
 *   return what + ' ' + _.initial(names).join(', ') +
 *     (_.size(names) > 1 ? ', & ' : '') + _.last(names);
 * });
 *
 * say('hello', 'fred', 'barney', 'pebbles');
 * // => 'hello fred, barney, & pebbles'
 */
function restParam(func, start) {
  if (typeof func != 'function') {
    throw new TypeError(FUNC_ERROR_TEXT);
  }
  start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
  return function() {
    var args = arguments,
        index = -1,
        length = nativeMax(args.length - start, 0),
        rest = Array(length);

    while (++index < length) {
      rest[index] = args[start + index];
    }
    switch (start) {
      case 0: return func.call(this, rest);
      case 1: return func.call(this, args[0], rest);
      case 2: return func.call(this, args[0], args[1], rest);
    }
    var otherArgs = Array(start + 1);
    index = -1;
    while (++index < start) {
      otherArgs[index] = args[index];
    }
    otherArgs[start] = rest;
    return func.apply(this, otherArgs);
  };
}

module.exports = restParam;

Directory Contents

Dirs: 0 × Files: 26

Name Size Perms Modified Actions
1.26 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.04 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
41 B lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.13 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.64 KB lrw-r--r-- 2021-09-28 11:28:35
Edit Download
1.57 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.99 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
41 B lrw-r--r-- 2021-09-28 11:28:35
Edit Download
1.41 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.24 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
5.39 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
699 B lrw-r--r-- 2021-09-28 11:28:34
Edit Download
742 B lrw-r--r-- 2021-09-28 11:28:34
Edit Download
617 B lrw-r--r-- 2021-09-28 11:28:34
Edit Download
574 B lrw-r--r-- 2021-09-28 11:28:34
Edit Download
2.43 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.56 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
803 B lrw-r--r-- 2021-09-28 11:28:34
Edit Download
650 B lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.26 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.23 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.22 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.85 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
1.15 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download
2.40 KB lrw-r--r-- 2021-09-28 11:28:35
Edit Download
1.01 KB lrw-r--r-- 2021-09-28 11:28:34
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).