@dynamic-labs/utils
Advanced tools
Comparing version 4.0.0-alpha.43 to 4.0.0-alpha.44
'use client' | ||
var version = "4.0.0-alpha.43"; | ||
var version = "4.0.0-alpha.44"; | ||
export { version }; |
{ | ||
"name": "@dynamic-labs/utils", | ||
"version": "4.0.0-alpha.43", | ||
"version": "4.0.0-alpha.44", | ||
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.", | ||
@@ -23,5 +23,5 @@ "author": "Dynamic Labs, Inc.", | ||
"tldts": "6.0.16", | ||
"@dynamic-labs/assert-package-version": "4.0.0-alpha.43", | ||
"@dynamic-labs/logger": "4.0.0-alpha.43", | ||
"@dynamic-labs/types": "4.0.0-alpha.43", | ||
"@dynamic-labs/assert-package-version": "4.0.0-alpha.44", | ||
"@dynamic-labs/logger": "4.0.0-alpha.44", | ||
"@dynamic-labs/types": "4.0.0-alpha.44", | ||
"buffer": "6.0.3", | ||
@@ -28,0 +28,0 @@ "eventemitter3": "5.0.1" |
@@ -1,2 +0,1 @@ | ||
import { Logger } from '@dynamic-labs/logger'; | ||
export declare const FALLBACK_UNDEFINED = "FALLBACK_UNDEFINED"; | ||
@@ -14,4 +13,2 @@ export type RetryableFnOptions<T> = { | ||
retryStrategy?: 'timeout-only' | 'rejection-only' | 'timeout-and-rejection'; | ||
/** Set the logger to be used */ | ||
logger?: Logger | typeof console; | ||
/** Ms to wait before a retry */ | ||
@@ -18,0 +15,0 @@ retryIntervalMs?: number; |
@@ -7,10 +7,3 @@ 'use client' | ||
const retryableFn = (fn_1, ...args_1) => __awaiter(void 0, [fn_1, ...args_1], void 0, function* (fn, options = {}) { | ||
const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', retryIntervalMs = 0, logger, } = options; | ||
logger === null || logger === void 0 ? void 0 : logger.debug('Configured retryableFn with options: ', { | ||
currentRetry, | ||
fallbackValue, | ||
maxRetries, | ||
retryStrategy, | ||
timeoutMs, | ||
}); | ||
const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', retryIntervalMs = 0, } = options; | ||
const timeoutPromise = new Promise((_, reject) => { | ||
@@ -26,5 +19,3 @@ setTimeout(() => { | ||
catch (err) { | ||
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn caught error: ', err); | ||
if (currentRetry >= maxRetries) { | ||
logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning/throwing fallback value', err, fallbackValue); | ||
if (fallbackValue instanceof Error) { | ||
@@ -42,14 +33,9 @@ throw fallbackValue; | ||
(retryStrategy === 'rejection-only' && !isTimeout); | ||
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn shouldRetry: ', shouldRetry); | ||
if (!shouldRetry) { | ||
if (fallbackValue instanceof Error) { | ||
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn throwing fallbackValue error: ', fallbackValue); | ||
throw err; | ||
} | ||
else if (fallbackValue === FALLBACK_UNDEFINED) { | ||
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning undefined'); | ||
return undefined; | ||
} | ||
logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning fallbackValue: ', fallbackValue); | ||
logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning fallback value', err); | ||
return fallbackValue; | ||
@@ -62,3 +48,2 @@ } | ||
fallbackValue, | ||
logger, | ||
maxRetries, | ||
@@ -65,0 +50,0 @@ retryIntervalMs, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
582311
4842
+ Added@dynamic-labs/assert-package-version@4.0.0-alpha.44(transitive)
+ Added@dynamic-labs/logger@4.0.0-alpha.44(transitive)
+ Added@dynamic-labs/types@4.0.0-alpha.44(transitive)
+ Addedtldts-core@6.1.68(transitive)
- Removed@dynamic-labs/assert-package-version@4.0.0-alpha.43(transitive)
- Removed@dynamic-labs/logger@4.0.0-alpha.43(transitive)
- Removed@dynamic-labs/types@4.0.0-alpha.43(transitive)
- Removedtldts-core@6.1.67(transitive)