rearg()

Creates a new wrapper function that will call the original the arguments in a different order.

This function is valid in v2.0.0 to v2.13.1. This function has been downloaded 24 times.

Parameters

{Function} fn
Function to be wrapped and called with the arguments in a different order.
{Array.} indices
Indices of the arguments to be passed. If the you want fn(a,b,c) to always be called as fn(c,a,b) you can supply [2,0,1].
{number=} opt_restIndex Optional, Default:indices.length
The starting index of the rest of the arguments that will be allowed to be passed in after those specified by indices. If Infinity, no more arguments will be passed no matter how many are sent to the wrapper function. If undefined, indices.length will be used.

Returns

{Function}
The wrapper function that will call fn with the arguments in the specified order.

Required Function

This function 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.