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
trusty-cms-6.3.1 node_modules/lodash/_overRest.js
immosquare-cleaner-0.1.51 node_modules/lodash/_overRest.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/_overRest.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/_overRest.js
immosquare-cleaner-0.1.50 node_modules/lodash/_overRest.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/lodash/_overRest.js
immosquare-cleaner-0.1.49 node_modules/lodash/_overRest.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/lodash/_overRest.js
immosquare-cleaner-0.1.48 node_modules/lodash/_overRest.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/lodash/_overRest.js