Compare commits

..

2 commits

Author SHA1 Message Date
Brent Schroeter
749626dbb1 0.2.0 2026-02-07 06:50:38 +00:00
Brent Schroeter
17225757d9 set retry config defaults without supplying empty object 2026-02-07 06:49:15 +00:00
3 changed files with 10 additions and 6 deletions

4
package-lock.json generated
View file

@ -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",

View file

@ -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",

View file

@ -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) {