Compare commits

..

No commits in common. "749626dbb1f936639fdb9d63f46dc09b079fa727" and "463b0db7596e973b8dbf878a76967a9f0b3d7a05" have entirely different histories.

3 changed files with 6 additions and 10 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "attq", "name": "attq",
"version": "0.2.0", "version": "0.1.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "attq", "name": "attq",
"version": "0.2.0", "version": "0.1.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.2.0", "version": "0.1.0",
"description": "Async Tiny Task Queue", "description": "Async Tiny Task Queue",
"repository": { "repository": {
"type": "git", "type": "git",
@ -8,11 +8,7 @@
}, },
"license": "MIT", "license": "MIT",
"author": "Brent Schroeter (https://brentsch.com)", "author": "Brent Schroeter (https://brentsch.com)",
"files": [ "files": ["dist", "LICENSE", "README.md"],
"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, backoffMs }: { { attempts = 6, backoffMs = (attempt) => 1000 * 2 ** attempt }: {
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) {