|
|
@ -3,25 +3,23 @@ |
|
|
|
### Instructions |
|
|
|
### Instructions |
|
|
|
|
|
|
|
|
|
|
|
Create a `retry` function, that takes 2 arguments |
|
|
|
Create a `retry` function, that takes 2 arguments |
|
|
|
- a `count`, that tells how many retries must be done |
|
|
|
- a `count` indicates maximum amount of retries |
|
|
|
- an async `callback`, that will be call every try |
|
|
|
- an async `callback`, that will be called on every try |
|
|
|
|
|
|
|
|
|
|
|
and it return a new function, passing arguments given to the |
|
|
|
`retry` returns a function that calls and returns value from `callback` |
|
|
|
callback on every tries. |
|
|
|
function passing its arguments and catches errors. If number of errors |
|
|
|
|
|
|
|
exceeds `count` then throw an `Error`. |
|
|
|
|
|
|
|
|
|
|
|
> for count of 3, the function will be called at most 4 times: |
|
|
|
> for count of 3, the function will be called at most 4 times: |
|
|
|
> the initial call + 3 retries. |
|
|
|
> the initial call + 3 retries. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Create a `timeout` function, that takes 2 arguments |
|
|
|
Create a `timeout` function, that takes 2 arguments |
|
|
|
- a `delay`, that tells how long to wait |
|
|
|
- a `delay` indicates maximum wait time |
|
|
|
- an async `callback`, that will be call |
|
|
|
- an async `callback`, that will be called |
|
|
|
|
|
|
|
|
|
|
|
and it return a new function, passing arguments given to the callback |
|
|
|
|
|
|
|
and either the async callback resolve before the delay is reached, |
|
|
|
|
|
|
|
in that case we return the value from the callback, |
|
|
|
|
|
|
|
or reject an error using the message `"timeout"` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
`timeout` returns a function either that calls and returns value from `callback` |
|
|
|
|
|
|
|
function passing its arguments or returns `Error('timeout')` if `callback` didn't |
|
|
|
|
|
|
|
resolve before `delay` time has reached. |
|
|
|
|
|
|
|
|
|
|
|
### Notions |
|
|
|
### Notions |
|
|
|
|
|
|
|
|
|
|
|