curry()

Creates a wrapper function that will only execute the given function once the number of arguments passed is at least a given amount. If the wrapper is called with too few arguments, those arguments will be recursively stored within a new wrapper function.

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

Parameters

{Function} fn
Function to be executed once enough arguments have been passed.
{number=} opt_argsNeeded Optional, Default:fn.length
Number of arguments needed to successfully invoke this function.
{boolean=} opt_curryRight Optional, Default:false
Indicates whether returned partial functions will group the arguments recursively from right-to-left.
{Array=} opt_presetArgs Optional, Default:[]
Arguments that will always be passed to fn. If opt_curryRight is true any arguments passed to the wrapper function will precede these arguments when invoking the function, otherwise any arguments passed to the wrapper function will come after these arguments when invoking the function.

Returns

{Function}
A wrapper function that will recursively create wrapper functions upon invocation until the cumulative number of arguments (excluding those specified in opt_presetArgs) amounts to opt_argsNeeded. If the minimum number of arguments are passed to this function it will invoke fn with all of the arguments passed in.

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.