Compare commits
2 commits
463b0db759
...
749626dbb1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
749626dbb1 | ||
|
|
17225757d9 |
3 changed files with 10 additions and 6 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "attq",
|
"name": "attq",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "attq",
|
"name": "attq",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.39.2",
|
"@eslint/js": "^9.39.2",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "attq",
|
"name": "attq",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"description": "Async Tiny Task Queue",
|
"description": "Async Tiny Task Queue",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
@ -8,7 +8,11 @@
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Brent Schroeter (https://brentsch.com)",
|
"author": "Brent Schroeter (https://brentsch.com)",
|
||||||
"files": ["dist", "LICENSE", "README.md"],
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"LICENSE",
|
||||||
|
"README.md"
|
||||||
|
],
|
||||||
"browser": "dist/index.min.js",
|
"browser": "dist/index.min.js",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.mjs",
|
"module": "dist/index.mjs",
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
*/
|
*/
|
||||||
export function withRetry<T extends unknown[], U>(
|
export function withRetry<T extends unknown[], U>(
|
||||||
fn: (...args: T) => Promise<U>,
|
fn: (...args: T) => Promise<U>,
|
||||||
{ attempts = 6, backoffMs = (attempt) => 1000 * 2 ** attempt }: {
|
{ attempts, backoffMs }: {
|
||||||
attempts: number;
|
attempts: number;
|
||||||
backoffMs(attempt: number): number;
|
backoffMs(attempt: number): number;
|
||||||
},
|
} = { attempts: 6, backoffMs: (attempt) => 1000 * 2 ** attempt },
|
||||||
): (...args: T) => Promise<U> {
|
): (...args: T) => Promise<U> {
|
||||||
return async (...args: T) => {
|
return async (...args: T) => {
|
||||||
for (let attempt = 0; attempt < attempts - 1; attempt += 1) {
|
for (let attempt = 0; attempt < attempts - 1; attempt += 1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue