Browse Source

docs(keep-trying-or-giveup): correct grammar

pull/1294/head
davhojt 2 years ago committed by Dav Hojt
parent
commit
a55dccefd6
  1. 32
      subjects/keep-trying-or-giveup/README.md

32
subjects/keep-trying-or-giveup/README.md

@ -2,30 +2,26 @@
### Instructions ### Instructions
Create a `retry` function, that takes 2 arguments Create a `retry` function, that takes 2 arguments:
- a `count` indicates maximum amount of retries - `count`: indicates maximum number of retries.
- an async `callback`, that will be called on every try - `callback`: an `async` function that will be invoked for every attempt.
`retry` returns a function that calls and returns value from `callback` `retry` returns a function that invokes the `callback` function. That function passes its arguments to `callback`, and returns the value from `callback`.
function passing its arguments and catches errors. If error is caught it
should return the `callback` function with catch. If number of errors
exceeds `count` then throw an `Error`.
> for count of 3, the function will be called at most 4 times: The function returned by `retry` must `catch` errors from `callback`. After that function has caught `count` errors, it must `throw` an `Error`.
> the initial call + 3 retries.
Create a `timeout` function, that takes 2 arguments > if `count` is 3, `callback` will be invoked at most 4 times, the initial call plus 3 retries.
- a `delay` indicates maximum wait time Create function named `timeout`, that takes 2 arguments:
- an async `callback`, that will be called
`timeout` returns a function either that calls and returns value from `callback` - `delay`: indicates maximum wait time.
function passing its arguments or returns `Error('timeout')` if `callback` didn't - `callback`: an asynchronous function that will be invoked.
resolve before `delay` time has reached.
`timeout` returns a function that invokes and returns the value from `callback`. The function must pass its arguments to `callback`. If `callback` does not resolve before `delay`, your function returns `Error('timeout')`.
### Notions ### Notions
- [nan-academy.github.io/js-training/examples/promise.js](https://nan-academy.github.io/js-training/examples/promises.js) - [Promises](https://nan-academy.github.io/js-training/examples/promises.js)
- [devdocs.io/dom/settimeout]( https://devdocs.io/dom/settimeout) - [setTimeout]( https://devdocs.io/dom/settimeout)
- [devdocs.io/javascript/global_objects/promise/race](https://devdocs.io/javascript/global_objects/promise/race) - [Promise.race](https://devdocs.io/javascript/global_objects/promise/race)

Loading…
Cancel
Save