@xylabs/retry
v5.0.87
Published
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Downloads
10,172
Readme
@xylabs/retry
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Reference
@xylabs/retry
Interfaces
| Interface | Description | | ------ | ------ | | RetryConfig | Configuration for retry behavior. | | RetryConfigWithComplete | Retry configuration extended with a custom completion check. |
Functions
| Function | Description | | ------ | ------ | | retry | Retries an async function with exponential backoff until it completes or retries are exhausted. |
functions
retry
function retry<T>(func: () => Promisable<T | undefined>, config?: RetryConfigWithComplete<T>): Promise<T | undefined>;Retries an async function with exponential backoff until it completes or retries are exhausted.
Type Parameters
| Type Parameter | Default type |
| ------ | ------ |
| T | unknown |
Parameters
| Parameter | Type | Description |
| ------ | ------ | ------ |
| func | () => Promisable<T | undefined> | The function to retry. |
| config? | RetryConfigWithComplete<T> | Optional retry configuration including backoff, interval, retries, and completion check. |
Returns
Promise<T | undefined>
The result of the function, or undefined if all retries were exhausted.
interfaces
RetryConfig
Configuration for retry behavior.
Extended by
Properties
| Property | Type | Description |
| ------ | ------ | ------ |
| backoff? | number | Multiplier applied to the interval after each retry. Defaults to 2. |
| interval? | number | Initial delay in milliseconds between retries. Defaults to 100. |
| retries? | number | Maximum number of retry attempts. Defaults to 0 (no retries). |
RetryConfigWithComplete
Retry configuration extended with a custom completion check.
Extends
Type Parameters
| Type Parameter | Default type |
| ------ | ------ |
| T | unknown |
Properties
| Property | Type | Description | Inherited from |
| ------ | ------ | ------ | ------ |
| backoff? | number | Multiplier applied to the interval after each retry. Defaults to 2. | RetryConfig.backoff |
| interval? | number | Initial delay in milliseconds between retries. Defaults to 100. | RetryConfig.interval |
| retries? | number | Maximum number of retry attempts. Defaults to 0 (no retries). | RetryConfig.retries |
| complete? | (result?: T) => boolean | Determines whether the result is considered complete. Defaults to checking for a defined value. | - |
Part of sdk-js
Maintainers
License
See the LICENSE file for license details
