@xylabs/retry 5.0.95 → 5.0.97
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/README.md +133 -77
- package/package.json +8 -11
package/README.md
CHANGED
|
@@ -1,67 +1,82 @@
|
|
|
1
1
|
# @xylabs/retry
|
|
2
2
|
|
|
3
|
-
[![
|
|
3
|
+
[![npm][npm-badge]][npm-link]
|
|
4
|
+
[![license][license-badge]][license-link]
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[![npm-badge][]][npm-link]
|
|
7
|
-
[![npm-downloads-badge][]][npm-link]
|
|
8
|
-
[![jsdelivr-badge][]][jsdelivr-link]
|
|
9
|
-
[![npm-license-badge][]](LICENSE)
|
|
10
|
-
[![codacy-badge][]][codacy-link]
|
|
11
|
-
[![codeclimate-badge][]][codeclimate-link]
|
|
12
|
-
[![snyk-badge][]][snyk-link]
|
|
13
|
-
[![socket-badge][]][socket-link]
|
|
6
|
+
> Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
14
7
|
|
|
8
|
+
## Install
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
Using npm:
|
|
17
11
|
|
|
12
|
+
```sh
|
|
13
|
+
npm install {{name}}
|
|
14
|
+
```
|
|
18
15
|
|
|
16
|
+
Using yarn:
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
```sh
|
|
19
|
+
yarn add {{name}}
|
|
20
|
+
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Using pnpm:
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add {{name}}
|
|
26
|
+
```
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
Using bun:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
bun add {{name}}
|
|
32
|
+
```
|
|
27
33
|
|
|
28
|
-
| Interface | Description |
|
|
29
|
-
| ------ | ------ |
|
|
30
|
-
| [RetryConfig](#interfaces/RetryConfig) | Configuration for retry behavior. |
|
|
31
|
-
| [RetryConfigWithComplete](#interfaces/RetryConfigWithComplete) | Retry configuration extended with a custom completion check. |
|
|
32
34
|
|
|
33
|
-
##
|
|
35
|
+
## License
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
| ------ | ------ |
|
|
37
|
-
| [retry](#functions/retry) | Retries an async function with exponential backoff until it completes or retries are exhausted. |
|
|
37
|
+
See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
## Reference
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
### packages
|
|
42
|
+
|
|
43
|
+
### retry
|
|
44
|
+
|
|
45
|
+
### .temp-typedoc
|
|
46
|
+
|
|
47
|
+
### functions
|
|
48
|
+
|
|
49
|
+
### <a id="retry"></a>retry
|
|
42
50
|
|
|
43
51
|
[**@xylabs/retry**](#../README)
|
|
44
52
|
|
|
45
53
|
***
|
|
46
54
|
|
|
47
55
|
```ts
|
|
48
|
-
function retry<T>(func
|
|
56
|
+
function retry<T>(func, config?): Promise<T | undefined>;
|
|
49
57
|
```
|
|
50
58
|
|
|
51
59
|
Retries an async function with exponential backoff until it completes or retries are exhausted.
|
|
52
60
|
|
|
53
61
|
## Type Parameters
|
|
54
62
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
### T
|
|
64
|
+
|
|
65
|
+
`T` = `unknown`
|
|
58
66
|
|
|
59
67
|
## Parameters
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
### func
|
|
70
|
+
|
|
71
|
+
() => `Promisable`\<`T` \| `undefined`\>
|
|
72
|
+
|
|
73
|
+
The function to retry.
|
|
74
|
+
|
|
75
|
+
### config?
|
|
76
|
+
|
|
77
|
+
[`RetryConfigWithComplete`](#../interfaces/RetryConfigWithComplete)\<`T`\>
|
|
78
|
+
|
|
79
|
+
Optional retry configuration including backoff, interval, retries, and completion check.
|
|
65
80
|
|
|
66
81
|
## Returns
|
|
67
82
|
|
|
@@ -69,9 +84,9 @@ Retries an async function with exponential backoff until it completes or retries
|
|
|
69
84
|
|
|
70
85
|
The result of the function, or undefined if all retries were exhausted.
|
|
71
86
|
|
|
72
|
-
### interfaces
|
|
87
|
+
### interfaces
|
|
73
88
|
|
|
74
|
-
|
|
89
|
+
### <a id="RetryConfig"></a>RetryConfig
|
|
75
90
|
|
|
76
91
|
[**@xylabs/retry**](#../README)
|
|
77
92
|
|
|
@@ -85,13 +100,35 @@ Configuration for retry behavior.
|
|
|
85
100
|
|
|
86
101
|
## Properties
|
|
87
102
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
103
|
+
### backoff?
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
optional backoff?: number;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Multiplier applied to the interval after each retry. Defaults to 2.
|
|
110
|
+
|
|
111
|
+
***
|
|
112
|
+
|
|
113
|
+
### interval?
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
optional interval?: number;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Initial delay in milliseconds between retries. Defaults to 100.
|
|
120
|
+
|
|
121
|
+
***
|
|
122
|
+
|
|
123
|
+
### retries?
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
optional retries?: number;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Maximum number of retry attempts. Defaults to 0 (no retries).
|
|
93
130
|
|
|
94
|
-
|
|
131
|
+
### <a id="RetryConfigWithComplete"></a>RetryConfigWithComplete
|
|
95
132
|
|
|
96
133
|
[**@xylabs/retry**](#../README)
|
|
97
134
|
|
|
@@ -105,55 +142,74 @@ Retry configuration extended with a custom completion check.
|
|
|
105
142
|
|
|
106
143
|
## Type Parameters
|
|
107
144
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
145
|
+
### T
|
|
146
|
+
|
|
147
|
+
`T` = `unknown`
|
|
111
148
|
|
|
112
149
|
## Properties
|
|
113
150
|
|
|
114
|
-
|
|
115
|
-
| ------ | ------ | ------ | ------ |
|
|
116
|
-
| <a id="backoff"></a> `backoff?` | `number` | Multiplier applied to the interval after each retry. Defaults to 2. | [`RetryConfig`](#RetryConfig).[`backoff`](RetryConfig.md#backoff) |
|
|
117
|
-
| <a id="interval"></a> `interval?` | `number` | Initial delay in milliseconds between retries. Defaults to 100. | [`RetryConfig`](#RetryConfig).[`interval`](RetryConfig.md#interval) |
|
|
118
|
-
| <a id="retries"></a> `retries?` | `number` | Maximum number of retry attempts. Defaults to 0 (no retries). | [`RetryConfig`](#RetryConfig).[`retries`](RetryConfig.md#retries) |
|
|
119
|
-
| <a id="complete"></a> `complete?` | (`result?`: `T`) => `boolean` | Determines whether the result is considered complete. Defaults to checking for a defined value. | - |
|
|
151
|
+
### backoff?
|
|
120
152
|
|
|
153
|
+
```ts
|
|
154
|
+
optional backoff?: number;
|
|
155
|
+
```
|
|
121
156
|
|
|
122
|
-
|
|
157
|
+
Multiplier applied to the interval after each retry. Defaults to 2.
|
|
123
158
|
|
|
124
|
-
|
|
159
|
+
### Inherited from
|
|
125
160
|
|
|
126
|
-
|
|
127
|
-
- [Matt Jones](https://github.com/jonesmac)
|
|
128
|
-
- [Joel Carter](https://github.com/JoelBCarter)
|
|
129
|
-
- [Jordan Trouw](https://github.com/jordantrouw)
|
|
161
|
+
[`RetryConfig`](#RetryConfig).[`backoff`](RetryConfig.md#backoff)
|
|
130
162
|
|
|
131
|
-
|
|
163
|
+
***
|
|
132
164
|
|
|
133
|
-
|
|
165
|
+
### interval?
|
|
134
166
|
|
|
135
|
-
|
|
167
|
+
```ts
|
|
168
|
+
optional interval?: number;
|
|
169
|
+
```
|
|
136
170
|
|
|
137
|
-
|
|
171
|
+
Initial delay in milliseconds between retries. Defaults to 100.
|
|
138
172
|
|
|
139
|
-
|
|
173
|
+
### Inherited from
|
|
140
174
|
|
|
141
|
-
[
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
175
|
+
[`RetryConfig`](#RetryConfig).[`interval`](RetryConfig.md#interval)
|
|
176
|
+
|
|
177
|
+
***
|
|
178
|
+
|
|
179
|
+
### retries?
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
optional retries?: number;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Maximum number of retry attempts. Defaults to 0 (no retries).
|
|
186
|
+
|
|
187
|
+
### Inherited from
|
|
151
188
|
|
|
152
|
-
[
|
|
153
|
-
|
|
189
|
+
[`RetryConfig`](#RetryConfig).[`retries`](RetryConfig.md#retries)
|
|
190
|
+
|
|
191
|
+
***
|
|
192
|
+
|
|
193
|
+
### complete?
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
optional complete?: (result?) => boolean;
|
|
197
|
+
```
|
|
154
198
|
|
|
155
|
-
|
|
156
|
-
[jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/retry
|
|
199
|
+
Determines whether the result is considered complete. Defaults to checking for a defined value.
|
|
157
200
|
|
|
158
|
-
|
|
159
|
-
|
|
201
|
+
### Parameters
|
|
202
|
+
|
|
203
|
+
#### result?
|
|
204
|
+
|
|
205
|
+
`T`
|
|
206
|
+
|
|
207
|
+
### Returns
|
|
208
|
+
|
|
209
|
+
`boolean`
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
[npm-badge]: https://img.shields.io/npm/v/@xylabs/retry.svg
|
|
213
|
+
[npm-link]: https://www.npmjs.com/package/@xylabs/retry
|
|
214
|
+
[license-badge]: https://img.shields.io/npm/l/@xylabs/retry.svg
|
|
215
|
+
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/retry",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.97",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"delay",
|
|
@@ -29,12 +29,10 @@
|
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
|
31
31
|
"types": "./dist/neutral/index.d.ts",
|
|
32
|
-
"import": "./dist/neutral/index.mjs",
|
|
33
32
|
"default": "./dist/neutral/index.mjs"
|
|
34
33
|
},
|
|
35
34
|
"./package.json": "./package.json"
|
|
36
35
|
},
|
|
37
|
-
"types": "./dist/neutral/index.d.ts",
|
|
38
36
|
"files": [
|
|
39
37
|
"dist",
|
|
40
38
|
"!**/*.bench.*",
|
|
@@ -43,18 +41,17 @@
|
|
|
43
41
|
"README.md"
|
|
44
42
|
],
|
|
45
43
|
"dependencies": {
|
|
46
|
-
"@xylabs/delay": "~5.0.
|
|
47
|
-
"@xylabs/promise": "~5.0.
|
|
44
|
+
"@xylabs/delay": "~5.0.97",
|
|
45
|
+
"@xylabs/promise": "~5.0.97"
|
|
48
46
|
},
|
|
49
47
|
"devDependencies": {
|
|
50
|
-
"@types/node": "^25.
|
|
51
|
-
"@xylabs/
|
|
52
|
-
"@xylabs/
|
|
53
|
-
"@xylabs/tsconfig": "~7.8.4",
|
|
48
|
+
"@types/node": "^25.6.0",
|
|
49
|
+
"@xylabs/toolchain": "~7.10.4",
|
|
50
|
+
"@xylabs/tsconfig": "~7.10.4",
|
|
54
51
|
"esbuild": "^0.28.0",
|
|
55
52
|
"typescript": "^5",
|
|
56
|
-
"vite": "^8.0.
|
|
57
|
-
"vitest": "^4.1.
|
|
53
|
+
"vite": "^8.0.8",
|
|
54
|
+
"vitest": "^4.1.4"
|
|
58
55
|
},
|
|
59
56
|
"engines": {
|
|
60
57
|
"node": ">=18"
|