()
| 15 | var attempt = 1; |
| 16 | |
| 17 | function doSomething() { |
| 18 | if (attempt > 10) { |
| 19 | console.log('Success!'); |
| 20 | strategy.reset(); |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | console.log('Attempt #' + attempt); |
| 25 | attempt++; |
| 26 | setTimeout(doSomething, strategy.next()); |
| 27 | } |
| 28 | |
| 29 | doSomething(); |