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",
"version": "0.2.0",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "attq",
"version": "0.2.0",
"version": "0.1.0",
"license": "MIT",
"devDependencies": {
"@eslint/js": "^9.39.2",

View file

@ -1,6 +1,6 @@
{
"name": "attq",
"version": "0.2.0",
"version": "0.1.0",
"description": "Async Tiny Task Queue",
"repository": {
"type": "git",
@ -8,11 +8,7 @@
},
"license": "MIT",
"author": "Brent Schroeter (https://brentsch.com)",
"files": [
"dist",
"LICENSE",
"README.md"
],
"files": ["dist", "LICENSE", "README.md"],
"browser": "dist/index.min.js",
"main": "dist/index.js",
"module": "dist/index.mjs",

View file

@ -3,10 +3,10 @@
*/
export function withRetry<T extends unknown[], U>(
fn: (...args: T) => Promise<U>,
{ attempts, backoffMs }: {
{ attempts = 6, backoffMs = (attempt) => 1000 * 2 ** attempt }: {
attempts: number;
backoffMs(attempt: number): number;
} = { attempts: 6, backoffMs: (attempt) => 1000 * 2 ** attempt },
},
): (...args: T) => Promise<U> {
return async (...args: T) => {
for (let attempt = 0; attempt < attempts - 1; attempt += 1) {