capProto()

Creates a wrapper function for a prototype function that can be capped (limited in the amount of arguments it can receive).

This function is valid in v2.7.0 to v2.24.3. This function has been downloaded 60 times.

Parameters

{Function|string} fn
The prototype function that will be called by the returned wrapper function. If it is a string it can refer to a prototype function by using either the "Array.prototype.slice" ("Prototype_Name.prototype.function_name") format, the "Array#slice" ("Prototype_Name#function_name") format or the "#slice" ("#function_name" for the 1st argument) format.
{number=} opt_maxArity Optional, Default:fn.length
The max number of arguments that will be accepted by the returned capped function.
{Array=} opt_staticArgs Optional, Default:[]
Arguments that will always be passed to fn.
{number=} opt_indexInArgs Optional, Default:opt_staticArgs.length
Position within opt_staticArgs to place the limited additional arguments if any are passed to the capped function. Negative position will be counted from the end of opt_staticArgs.

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 (not including the 1st argument which is the context argument).

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.