@xylabs/retry 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/retry.ts +1 -1
- package/xy.config.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/retry.ts"],"sourcesContent":["import { delay } from '@xylabs/delay'\nimport { Promisable } from '@xylabs/promise'\n\nexport interface RetryConfig {\n backoff?: number\n interval?: number\n retries?: number\n}\n\nexport interface RetryConfigWithComplete<T = unknown> extends RetryConfig {\n complete?: (result?: T) => boolean\n}\n\nexport const retry = async <T = unknown>(func: () => Promisable<T | undefined>, config?: RetryConfigWithComplete<T>): Promise<T | undefined> => {\n const { complete = (value: T | undefined) => value !== undefined, retries = 0, interval = 100, backoff = 2 } = config ?? {}\n const result = await func()\n if (complete(result)) {\n return result\n }\n if (retries <= 0) {\n return undefined\n }\n await delay(interval)\n return retry(func, { backoff, complete, interval: interval * backoff, retries: retries - 1 })\n}\n"],"mappings":";AAAA,SAAS,aAAa;AAaf,IAAM,QAAQ,OAAoB,MAAuC,WAAgE;AAC9I,QAAM,EAAE,WAAW,CAAC,UAAyB,UAAU,QAAW,UAAU,GAAG,WAAW,KAAK,UAAU,EAAE,IAAI,UAAU,CAAC;AAC1H,QAAM,SAAS,MAAM,KAAK;AAC1B,MAAI,SAAS,MAAM,GAAG;AACpB,WAAO;AAAA,EACT;AACA,MAAI,WAAW,GAAG;AAChB,WAAO;AAAA,EACT;AACA,QAAM,MAAM,QAAQ;AACpB,SAAO,MAAM,MAAM,EAAE,SAAS,UAAU,UAAU,WAAW,SAAS,SAAS,UAAU,EAAE,CAAC;AAC9F;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/retry.ts"],"sourcesContent":["import { delay } from '@xylabs/delay'\nimport type { Promisable } from '@xylabs/promise'\n\nexport interface RetryConfig {\n backoff?: number\n interval?: number\n retries?: number\n}\n\nexport interface RetryConfigWithComplete<T = unknown> extends RetryConfig {\n complete?: (result?: T) => boolean\n}\n\nexport const retry = async <T = unknown>(func: () => Promisable<T | undefined>, config?: RetryConfigWithComplete<T>): Promise<T | undefined> => {\n const { complete = (value: T | undefined) => value !== undefined, retries = 0, interval = 100, backoff = 2 } = config ?? {}\n const result = await func()\n if (complete(result)) {\n return result\n }\n if (retries <= 0) {\n return undefined\n }\n await delay(interval)\n return retry(func, { backoff, complete, interval: interval * backoff, retries: retries - 1 })\n}\n"],"mappings":";AAAA,SAAS,aAAa;AAaf,IAAM,QAAQ,OAAoB,MAAuC,WAAgE;AAC9I,QAAM,EAAE,WAAW,CAAC,UAAyB,UAAU,QAAW,UAAU,GAAG,WAAW,KAAK,UAAU,EAAE,IAAI,UAAU,CAAC;AAC1H,QAAM,SAAS,MAAM,KAAK;AAC1B,MAAI,SAAS,MAAM,GAAG;AACpB,WAAO;AAAA,EACT;AACA,MAAI,WAAW,GAAG;AAChB,WAAO;AAAA,EACT;AACA,QAAM,MAAM,QAAQ;AACpB,SAAO,MAAM,MAAM,EAAE,SAAS,UAAU,UAAU,WAAW,SAAS,SAAS,UAAU,EAAE,CAAC;AAC9F;","names":[]}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"bugs": {
|
|
10
10
|
"email": "support@xylabs.com",
|
|
11
|
-
"url": "https://github.com/xylabs/sdk-js/issues"
|
|
11
|
+
"url": "git+https://github.com/xylabs/sdk-js/issues"
|
|
12
12
|
},
|
|
13
13
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
14
14
|
"exports": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"esm"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@xylabs/delay": "^4.0.
|
|
33
|
-
"@xylabs/promise": "^4.0.
|
|
32
|
+
"@xylabs/delay": "^4.0.2",
|
|
33
|
+
"@xylabs/promise": "^4.0.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.15",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
},
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
49
|
-
"url": "https://github.com/xylabs/sdk-js.git"
|
|
49
|
+
"url": "git+https://github.com/xylabs/sdk-js.git"
|
|
50
50
|
},
|
|
51
51
|
"sideEffects": false,
|
|
52
|
-
"version": "4.0.
|
|
52
|
+
"version": "4.0.2",
|
|
53
53
|
"type": "module"
|
|
54
54
|
}
|
package/src/retry.ts
CHANGED
package/xy.config.ts
CHANGED