Sha256: 8833534359cb66fde3c020f57e1280f9626c806088e6b9eaf51953b3c849ce36

Contents?: true

Size: 1.07 KB

Versions: 265

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

265 entries across 263 versions & 29 rubygems

Version Path
clapton-0.0.13 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.6 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.5 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.4 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.3 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.2 lib/clapton/javascripts/node_modules/lodash/_overRest.js
clapton-0.0.1 lib/clapton/javascripts/node_modules/lodash/_overRest.js
immosquare-cleaner-0.1.47 node_modules/lodash/_overRest.js
immosquare-cleaner-0.1.46 node_modules/lodash/_overRest.js
immosquare-cleaner-0.1.45 node_modules/lodash/_overRest.js
immosquare-cleaner-0.1.44 node_modules/lodash/_overRest.js
boring_generators-0.14.0 tmp/templates/app_template/node_modules/lodash/_overRest.js
immosquare-cleaner-0.1.43 node_modules/lodash/_overRest.js
immosquare-cleaner-0.1.42 node_modules/lodash/_overRest.js