@forwardimpact/libutil
Advanced tools
+2
-2
| { | ||
| "name": "@forwardimpact/libutil", | ||
| "version": "0.1.83", | ||
| "version": "0.1.84", | ||
| "description": "Cross-cutting utilities: retry, hashing, token counting, and project discovery.", | ||
@@ -47,3 +47,3 @@ "keywords": [ | ||
| "devDependencies": { | ||
| "@forwardimpact/libharness": "^0.1.5" | ||
| "@forwardimpact/libmock": "^0.1.0" | ||
| }, | ||
@@ -50,0 +50,0 @@ "engines": { |
+8
-2
@@ -0,1 +1,3 @@ | ||
| const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
| /** | ||
@@ -7,2 +9,3 @@ * Retry class for handling transient errors with exponential backoff | ||
| #delay; | ||
| #sleep; | ||
@@ -14,2 +17,4 @@ /** | ||
| * @param {number} [config.delay] - Initial delay in milliseconds (default: 1000) | ||
| * @param {(ms: number) => Promise<void>} [config.sleep] - Injectable sleep | ||
| * for deterministic tests (default: real setTimeout-based wait). | ||
| */ | ||
@@ -19,2 +24,3 @@ constructor(config = {}) { | ||
| this.#delay = config.delay ?? 1000; | ||
| this.#sleep = config.sleep ?? defaultSleep; | ||
| } | ||
@@ -93,3 +99,3 @@ | ||
| const wait = exponentialDelay + jitter; | ||
| await new Promise((resolve) => setTimeout(resolve, wait)); | ||
| await this.#sleep(wait); | ||
| continue; | ||
@@ -107,3 +113,3 @@ } | ||
| const wait = exponentialDelay + jitter; | ||
| await new Promise((resolve) => setTimeout(resolve, wait)); | ||
| await this.#sleep(wait); | ||
| continue; | ||
@@ -110,0 +116,0 @@ } |
59053
0.37%1278
0.39%