cap()

Puts a cap (limit) on the amount of arguments that a function can receive.

This function is valid in v2.0.0. This function has been downloaded 0 times.

Parameters

{Function} fn
The function whose argument count will be capped off (limited).
{number=} opt_maxArity Optional, Default:fn.length
The max number of arguments that will be passed into fn.

Returns

{Function}
Returns a function that will call fn with the passed in arguments when invoked, but it will limit the argument count to the value opt_maxArity. When calling this newly created function, it will behave like this: fn.apply(this, YourJS.slice(arguments, 0, opt_maxArity)).

Required Function

This function directly requires the following function which is included automatically:

  • slice()
    Slice does not modify the original array, but instead returns a shallow copy of elements from the original array.