Sha256: 8833534359cb66fde3c020f57e1280f9626c806088e6b9eaf51953b3c849ce36

Contents?: true

Size: 1.07 KB

Versions: 264

Compression:

Stored size: 1.07 KB

Contents

var apply = require('./_apply');

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

/**
 * A specialized version of `baseRest` which transforms the rest array.
 *
 * @private
 * @param {Function} func The function to apply a rest parameter to.
 * @param {number} [start=func.length-1] The start position of the rest parameter.
 * @param {Function} transform The rest array transform.
 * @returns {Function} Returns the new function.
 */
function overRest(func, start, transform) {
  start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  return function() {
    var args = arguments,
        index = -1,
        length = nativeMax(args.length - start, 0),
        array = Array(length);

    while (++index < length) {
      array[index] = args[start + index];
    }
    index = -1;
    var otherArgs = Array(start + 1);
    while (++index < start) {
      otherArgs[index] = args[index];
    }
    otherArgs[start] = transform(array);
    return apply(func, this, otherArgs);
  };
}

module.exports = overRest;

Version data entries

264 entries across 262 versions & 29 rubygems

Version Path
appmap-0.71.0 ./node_modules/lodash/_overRest.js
disco_app-0.16.1 test/dummy/node_modules/lodash/_overRest.js
appmap-0.70.2 ./node_modules/lodash/_overRest.js
sumomo-0.8.14 data/sumomo/api_modules/node_modules/lodash/_overRest.js
appmap-0.70.1 ./node_modules/lodash/_overRest.js
appmap-0.70.0 ./node_modules/lodash/_overRest.js
appmap-0.69.0 ./node_modules/lodash/_overRest.js
sumomo-0.8.13 data/sumomo/api_modules/node_modules/lodash/_overRest.js
appmap-0.68.2 ./node_modules/lodash/_overRest.js
appmap-0.68.1 ./node_modules/lodash/_overRest.js
disco_app-0.15.2 test/dummy/node_modules/lodash/_overRest.js
appmap-0.68.0 ./node_modules/lodash/_overRest.js
appmap-0.67.1 ./node_modules/lodash/_overRest.js
trusty-cms-5.0.3 node_modules/lodash/_overRest.js
trusty-cms-5.0.2 node_modules/lodash/_overRest.js
appmap-0.67.0 ./node_modules/lodash/_overRest.js
disco_app-0.18.4 test/dummy/node_modules/lodash/_overRest.js
disco_app-0.18.1 test/dummy/node_modules/lodash/_overRest.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/lodash/_overRest.js
disco_app-0.14.0 test/dummy/node_modules/lodash/_overRest.js