limit()

Creates a wrapper function which when called will call the given function, but only a maximum amount of times as specified.

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

Parameters

{Function} fn
The function which will only be called a limited amount of times.
{number=} opt_callLimit Optional, Default:1
The maximum amount of times the returned wrapper function can be called.
{string} opt_errorMessage
If given, once the call limit is reached every subsequent call to the returned wrapper function will throw an error with this message. If not given no error will be thrown.

Returns

{Function}
A wrapper function that is limited in the amount of times it will call fn.