Skip to content

Commit 7c3e9e1

Browse files
committed
chore(std/retry): rename to with-retry
1 parent 0066ca5 commit 7c3e9e1

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

packages/std/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"./merge": "./src/merge/index.ts",
2121
"./set-interval": "./src/set-interval/index.ts",
2222
"./sleep": "./src/sleep/index.ts",
23-
"./trampoline": "./src/trampoline/index.ts"
23+
"./trampoline": "./src/trampoline/index.ts",
24+
"./with-retry": "./src/with-retry/index.ts"
2425
},
2526
"files": [
2627
"dist"
@@ -55,6 +56,10 @@
5556
"types": "./dist/trampoline/index.d.ts",
5657
"default": "./dist/trampoline/index.js"
5758
},
59+
"./with-retry": {
60+
"types": "./dist/with-retry/index.d.ts",
61+
"default": "./dist/with-retry/index.js"
62+
},
5863
"./package.json": "./package.json"
5964
},
6065
"main": "./dist/index.js",

packages/std/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export * from './async-iterator'
22
export * from './base64'
33
export * from './merge'
4-
export * from './retry'
54
export * from './set-interval'
65
export * from './sleep'
76
export * from './trampoline'
7+
export * from './with-retry'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const defaults: ToRetriableOptions = {
1818
*
1919
* @returns A wrapped function with the same signature as func
2020
*/
21-
export const toRetriable = <A, R>(func: (...args: A[]) => Promise<R>, options?: Partial<ToRetriableOptions>): (...args: A[]) => Promise<R> => {
21+
export const withRetry = <A, R>(func: (...args: A[]) => Promise<R>, options?: Partial<ToRetriableOptions>): (...args: A[]) => Promise<R> => {
2222
let retryCount = 0
2323
const opts = merge(defaults, options)
2424

@@ -32,7 +32,7 @@ export const toRetriable = <A, R>(func: (...args: A[]) => Promise<R>, options?:
3232
if (retryCount < opts.retry) {
3333
retryCount++
3434
await sleep(opts.retryDelay)
35-
return toRetriable(func, { ...options, retry: opts.retry - retryCount })(args)
35+
return withRetry(func, { ...options, retry: opts.retry - retryCount })(args)
3636
}
3737
else {
3838
throw err

0 commit comments

Comments
 (0)