MCPcopy Create free account
hub / github.com/RubyLouvre/anu / overRest

Function overRest

test/babel.js:53707–53726  ·  view source on GitHub ↗

* 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.

(func, start, transform)

Source from the content-addressed store, hash-verified

53705 * @returns {Function} Returns the new function.
53706 */
53707 function overRest(func, start, transform) {
53708 start = nativeMax(start === undefined ? func.length - 1 : start, 0);
53709 return function () {
53710 var args = arguments,
53711 index = -1,
53712 length = nativeMax(args.length - start, 0),
53713 array = Array(length);
53714
53715 while (++index < length) {
53716 array[index] = args[start + index];
53717 }
53718 index = -1;
53719 var otherArgs = Array(start + 1);
53720 while (++index < start) {
53721 otherArgs[index] = args[index];
53722 }
53723 otherArgs[start] = transform(array);
53724 return apply(func, this, otherArgs);
53725 };
53726 }
53727
53728 module.exports = overRest;
53729

Callers 1

baseRestFunction · 0.85

Calls 2

transformFunction · 0.85
applyFunction · 0.85

Tested by

no test coverage detected