Creates a new `RetryOperation` where `timeouts` is an array where each value is
a timeout given in milliseconds.
#### retryOperation.errors()
Returns an array of all errors that have been passed to
`retryOperation.retry()` so far.
#### retryOperation.mainError()
A reference to the error object that occured most frequently. Errors are
compared using the `error.message` property.
If multiple error messages occured the same amount of time, the last error
object with that message is returned.
If no errors occured so far, the value is `null`.
#### retryOperation.attempt(fn, timeoutOps)
Defines the function `fn` that is to be retried and executes it for the first
time right away. The `fn` function can receive an optional `currentAttempt` callback that represents the number of attempts to execute `fn` so far.
Optionally defines `timeoutOps` which is an object having a property `timeout` in miliseconds and a property `cb` callback function.
Whenever your retry operation takes longer than `timeout` to execute, the timeout callback function `cb` is called.
#### retryOperation.try(fn)
This is an alias for `retryOperation.attempt(fn)`. This is deprecated.
#### retryOperation.start(fn)
This is an alias for `retryOperation.attempt(fn)`. This is deprecated.
#### retryOperation.retry(error)
Returns `false` when no `error` value is given, or the maximum amount of retries
has been reached.
Otherwise it returns `true`, and retries the operation after the timeout for
the current attempt number.
#### retryOperation.attempts()
Returns an int representing the number of attempts it took to call `fn` before it was successful.
## License
retry is licensed under the MIT license.
#Changelog
0.6.0 Introduced optional timeOps parameter for the attempt() function which is an object having a property timeout in miliseconds and a property cb callback function. Whenever your retry operation takes longer than timeout to execute, the timeout callback function cb is called.
0.5.0 Some minor refactorings.
0.4.0 Changed retryOperation.try() to retryOperation.attempt(). Deprecated the aliases start() and try() for it.
0.3.0 Added retryOperation.start() which is an alias for retryOperation.try().
0.2.0 Added attempts() function and parameter to retryOperation.try() representing the number of attempts it took to call fn().