You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-4
Original file line number
Diff line number
Diff line change
@@ -1445,30 +1445,40 @@ result (if any) of the final attempt.
1445
1445
1446
1446
__Arguments__
1447
1447
1448
-
* `opts` - Can be either an object with `times` and `interval` or a number. `times` is how many attempts should be made before giving up. `interval` is how long to wait inbetween attempts. Defaults to {times: 5, interval: 0}
1449
-
* if a number is passed in it sets `times` only (with `interval` defaulting to 0).
1448
+
* `opts` - Can be either an object with `times` and `interval` or a number.
1449
+
* `times` - The number of attempts to make before giving up. The default is `5`.
1450
+
* `interval` - The time to wait between retries, in milliseconds. The default is `0`.
1451
+
* If `opts` is a number, the number specifies the number of times to retry, with the default interval of `0`.
1450
1452
* `task(callback, results)` - A function which receives two arguments: (1) a `callback(err, result)`
1451
1453
which must be called when finished, passing `err` (which can be `null`) and the `result` of
1452
1454
the function's execution, and (2) a `results` object, containing the results of
1453
1455
the previously executed functions (if nested inside another control flow).
1454
1456
* `callback(err, results)` - An optional callback which is called when the
1455
1457
task has succeeded, or after the final failed attempt. It receives the `err` and `result` arguments of the last attempt at completing the `task`.
1456
1458
1457
-
The [`retry`](#retry) function can be used as a stand-alone control flow by passing a
1458
-
callback, as shown below:
1459
+
The [`retry`](#retry) function can be used as a stand-alone control flow by passing a callback, as shown below:
1459
1460
1460
1461
```js
1462
+
// try calling apiMethod 3 times
1461
1463
async.retry(3, apiMethod, function(err, result) {
1462
1464
// do something with the result
1463
1465
});
1464
1466
```
1465
1467
1466
1468
```js
1469
+
// try calling apiMethod 3 times, waiting 200 ms between each retry
0 commit comments