@xylabs/retry 5.0.84 → 5.0.86
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 +31 -107
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
|
|
18
20
|
## Reference
|
|
19
21
|
|
|
20
22
|
**@xylabs/retry**
|
|
@@ -23,12 +25,16 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
23
25
|
|
|
24
26
|
## Interfaces
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
| Interface | Description |
|
|
29
|
+
| ------ | ------ |
|
|
30
|
+
| [RetryConfig](#interfaces/RetryConfig) | Configuration for retry behavior. |
|
|
31
|
+
| [RetryConfigWithComplete](#interfaces/RetryConfigWithComplete) | Retry configuration extended with a custom completion check. |
|
|
28
32
|
|
|
29
33
|
## Functions
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
| Function | Description |
|
|
36
|
+
| ------ | ------ |
|
|
37
|
+
| [retry](#functions/retry) | Retries an async function with exponential backoff until it completes or retries are exhausted. |
|
|
32
38
|
|
|
33
39
|
### functions
|
|
34
40
|
|
|
@@ -39,30 +45,23 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
39
45
|
***
|
|
40
46
|
|
|
41
47
|
```ts
|
|
42
|
-
function retry<T>(func
|
|
48
|
+
function retry<T>(func: () => Promisable<T | undefined>, config?: RetryConfigWithComplete<T>): Promise<T | undefined>;
|
|
43
49
|
```
|
|
44
50
|
|
|
45
51
|
Retries an async function with exponential backoff until it completes or retries are exhausted.
|
|
46
52
|
|
|
47
53
|
## Type Parameters
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
`T`
|
|
55
|
+
| Type Parameter | Default type |
|
|
56
|
+
| ------ | ------ |
|
|
57
|
+
| `T` | `unknown` |
|
|
52
58
|
|
|
53
59
|
## Parameters
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
() => `Promisable`\<`T` \| `undefined`\>
|
|
58
|
-
|
|
59
|
-
The function to retry.
|
|
60
|
-
|
|
61
|
-
### config?
|
|
62
|
-
|
|
63
|
-
[`RetryConfigWithComplete`](#../interfaces/RetryConfigWithComplete)\<`T`\>
|
|
64
|
-
|
|
65
|
-
Optional retry configuration including backoff, interval, retries, and completion check.
|
|
61
|
+
| Parameter | Type | Description |
|
|
62
|
+
| ------ | ------ | ------ |
|
|
63
|
+
| `func` | () => `Promisable`\<`T` \| `undefined`\> | The function to retry. |
|
|
64
|
+
| `config?` | [`RetryConfigWithComplete`](#../interfaces/RetryConfigWithComplete)\<`T`\> | Optional retry configuration including backoff, interval, retries, and completion check. |
|
|
66
65
|
|
|
67
66
|
## Returns
|
|
68
67
|
|
|
@@ -86,33 +85,11 @@ Configuration for retry behavior.
|
|
|
86
85
|
|
|
87
86
|
## Properties
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
Multiplier applied to the interval after each retry. Defaults to 2.
|
|
96
|
-
|
|
97
|
-
***
|
|
98
|
-
|
|
99
|
-
### interval?
|
|
100
|
-
|
|
101
|
-
```ts
|
|
102
|
-
optional interval: number;
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
Initial delay in milliseconds between retries. Defaults to 100.
|
|
106
|
-
|
|
107
|
-
***
|
|
108
|
-
|
|
109
|
-
### retries?
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
optional retries: number;
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Maximum number of retry attempts. Defaults to 0 (no retries).
|
|
88
|
+
| Property | Type | Description |
|
|
89
|
+
| ------ | ------ | ------ |
|
|
90
|
+
| <a id="backoff"></a> `backoff?` | `number` | Multiplier applied to the interval after each retry. Defaults to 2. |
|
|
91
|
+
| <a id="interval"></a> `interval?` | `number` | Initial delay in milliseconds between retries. Defaults to 100. |
|
|
92
|
+
| <a id="retries"></a> `retries?` | `number` | Maximum number of retry attempts. Defaults to 0 (no retries). |
|
|
116
93
|
|
|
117
94
|
### <a id="RetryConfigWithComplete"></a>RetryConfigWithComplete
|
|
118
95
|
|
|
@@ -128,71 +105,18 @@ Retry configuration extended with a custom completion check.
|
|
|
128
105
|
|
|
129
106
|
## Type Parameters
|
|
130
107
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
`T`
|
|
108
|
+
| Type Parameter | Default type |
|
|
109
|
+
| ------ | ------ |
|
|
110
|
+
| `T` | `unknown` |
|
|
134
111
|
|
|
135
112
|
## Properties
|
|
136
113
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
Multiplier applied to the interval after each retry. Defaults to 2.
|
|
144
|
-
|
|
145
|
-
### Inherited from
|
|
146
|
-
|
|
147
|
-
[`RetryConfig`](#RetryConfig).[`backoff`](RetryConfig.md#backoff)
|
|
148
|
-
|
|
149
|
-
***
|
|
150
|
-
|
|
151
|
-
### interval?
|
|
152
|
-
|
|
153
|
-
```ts
|
|
154
|
-
optional interval: number;
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
Initial delay in milliseconds between retries. Defaults to 100.
|
|
158
|
-
|
|
159
|
-
### Inherited from
|
|
160
|
-
|
|
161
|
-
[`RetryConfig`](#RetryConfig).[`interval`](RetryConfig.md#interval)
|
|
162
|
-
|
|
163
|
-
***
|
|
164
|
-
|
|
165
|
-
### retries?
|
|
166
|
-
|
|
167
|
-
```ts
|
|
168
|
-
optional retries: number;
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
Maximum number of retry attempts. Defaults to 0 (no retries).
|
|
172
|
-
|
|
173
|
-
### Inherited from
|
|
174
|
-
|
|
175
|
-
[`RetryConfig`](#RetryConfig).[`retries`](RetryConfig.md#retries)
|
|
176
|
-
|
|
177
|
-
***
|
|
178
|
-
|
|
179
|
-
### complete()?
|
|
180
|
-
|
|
181
|
-
```ts
|
|
182
|
-
optional complete: (result?) => boolean;
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
Determines whether the result is considered complete. Defaults to checking for a defined value.
|
|
186
|
-
|
|
187
|
-
### Parameters
|
|
188
|
-
|
|
189
|
-
#### result?
|
|
190
|
-
|
|
191
|
-
`T`
|
|
192
|
-
|
|
193
|
-
### Returns
|
|
194
|
-
|
|
195
|
-
`boolean`
|
|
114
|
+
| Property | Type | Description | Inherited from |
|
|
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. | - |
|
|
196
120
|
|
|
197
121
|
|
|
198
122
|
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/retry",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.86",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"delay",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"!**/*.test.*"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@xylabs/delay": "~5.0.
|
|
46
|
-
"@xylabs/promise": "~5.0.
|
|
45
|
+
"@xylabs/delay": "~5.0.86",
|
|
46
|
+
"@xylabs/promise": "~5.0.86"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@xylabs/ts-scripts-yarn3": "~7.4.
|
|
50
|
-
"@xylabs/tsconfig": "~7.4.
|
|
49
|
+
"@xylabs/ts-scripts-yarn3": "~7.4.16",
|
|
50
|
+
"@xylabs/tsconfig": "~7.4.16",
|
|
51
51
|
"typescript": "~5.9.3",
|
|
52
52
|
"vitest": "^4.0.18"
|
|
53
53
|
},
|