A set of premade reducer functions are included. These can be used by the reducer option on debounce and throttle to determine what the arguments to the wrapped function should be.
callback for retry to determine the arguments to the function to retry.
the type of function to retry.
The attempt number for the next try.
The current delay before retrying.
The error from the current attempt.
The arguments for the function
A delay, list of delays or [[RetryNextDelayFunction|callback]] for retry to use when determining the delay between attempts.
Function for determining a how long to wait after the given attempt
The current attempt number.
The previous delay.
The error from the current attempt.
The new delay in milliseconds.
Types of retry errors
A function used to determine if to stop for the given retry attempt.
Errors thrown by this function will cause retry to reject with the errorTypes of retry errors
The attempt number for the next try.
The current delay before retrying.
The error from the current attempt.
true or a message to stop trying and reject with the given message.
the type of the value.
A callback that will return a value after wait is completed.
the type of the value.
the value or promise to return the value
A reducer used to create the invocation arguments for a function over multiple calls.
It receives the current invocation arguments and the call arguments and returns the new invocation arguments.
The current invocation arguments for the main function. The first call will be an empty array.
The arguments given to the latest call.
The new invocation arguments.
An implementation ArgumentsReducer for a particular invocation function.
the type of the invocation function.
the arguments or type of the call function.
Ensure multiple calls to a function will only execute it when it has been inactive (no more calls) for a specified delay.
Execution always happens asynchronously.
If the delay is 0
execution will be scheduled to occur after the current
runtime event loop.
The debounced function returns a promise that resolves to the return value
of func
.
By default the arguments to func
are the latest arguments given to the
debounced function. For custom behaviour pass an argumentsReducer
function.
The function to debounce
The number of milliseconds on inactivity before the function will be executed. .
the debounced function
Retry the wrapped function according to the
the function to retry.
a delay in milliseconds, an array of millisecond delays or callback to determine the delay before the next attempt.
the number of attempts, or callback to
determine when retry should stop retrying func
.
an array or callback to
provide arguments to func
Ensure multiple calls to a function will only execute at most once every
delay
milliseconds.
The execution will always happens asynchronously. If the delay is 0
then
execution will occur after the current runtime event loop.
The throttled function returns a promise that resolves to the return value
of func
.
By default the arguments to func
are the latest arguments given to the
throttled function. For custom behaviour pass an argumentsReducer
function.
The function to throttle
The number of milliseconds between executions.
Debounce options
The throttled function
Resolves after a given delay, optionally with a value.
If the delay is 0
the promises will resolve after the current
runtime event loop.
The time in milliseconds before the value is returned.
A function or value that will be returned after waiting.
A promise that resolves with the value/function result. The promise has 2 extra functions defined:
cancel
cancels the result and rejects the promise.stop
stops waiting and resolves the promised value.Reducer that provices the invocation function with a single array of arrays of all calls.
// the sequence of calls below to a call function
call(1);
call(1,2,3);
call(4,5);
call([1]);
call('last');
// would be the equivalent to the invoke call below.
invoke([[1], [1, 2, 3], [4, 5], [[1]], ['last']]);
An arguments reducer that takes combines all arguments from every call function into an array that is used as the first argument to the invoke function.
Example:
// the sequence of calls below to a call function
call(1);
call(1,2,3);
call(4,5);
call([1]);
call('last');
// would be the equivalent to the invoke call below.
invoke([1, 1, 2, 3, 4, 5, [1], 'last']);
Reducer that extends the invocation arguments array with all arguments given to it.
Example:
// the sequence of calls below to a call function
call(1);
call(1,2,3);
call(4,5);
call([1]);
call('last');
// would be the equivalent to the invoke call below.
invoke(1, 1, 2, 3, 4, 5, [1], 'last');
An arguments reducer that will use the latest call arguments as the invocation arguments.
Example:
// the sequence of calls below to a call function
call(1);
call(1,2,3);
call(4,5);
call([1]);
call('last');
// would be the equivalent to the invoke call below.
invoke('last');
Generated using TypeDoc
An array of arguments or callback for retry to use when calling it's function