New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts-retry

Package Overview
Dependencies
Maintainers
0
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-retry - npm Package Compare versions

Comparing version

to
6.0.0

lib/cjs/retry/utils/erros/abortError.d.ts

17

changelog.md

@@ -0,1 +1,18 @@

# 6.0.0
onError function may now return boolean:
- when returning nothing (behavior until 5.x): retries continue
- when returnin true, retries continue
- when returning flase, retries stops and an AbortError is thrown
The behavior of previuos release is preserve. If you don't want to use this functionality you do not need do
do any change in tour code
AbortError:
An error thrown when reties are aborted due to an exception
getError return the last error
getCurrentTry the aborte try
# 5.0.1

@@ -2,0 +19,0 @@

4

lib/cjs/retry/index.d.ts
export type { RetryOptions } from "./options";
export { getDefaultRetryOptions, setDefaultRetryOptions } from "./options";
export { retry, retryAsync } from "./retry";
export type { TooManyTries } from "./tooManyTries";
export { isTooManyTries } from "./tooManyTries";
export type { TooManyTries } from "./utils/erros/tooManyTries";
export { isTooManyTries } from "./utils/erros/tooManyTries";
export type { RetryUtilsOptions } from "./utils";
export { retryAsyncUntilDefined, retryAsyncUntilDefinedDecorator, retryAsyncUntilTruthy, retryAsyncUntilTruthyDecorator, retryUntilDefined, retryUntilDefinedDecorator, retryUntilTruthy, retryUntilTruthyDecorator, retryAsyncUntilResponse, retryAsyncUntilResponseDecorator, createExponetialDelay, createMutiplicableDelay, createRandomDelay, retryAsyncDecorator, retryDecorator, } from "./utils";

@@ -10,3 +10,3 @@ "use strict";

Object.defineProperty(exports, "retryAsync", { enumerable: true, get: function () { return retry_1.retryAsync; } });
var tooManyTries_1 = require("./tooManyTries");
var tooManyTries_1 = require("./utils/erros/tooManyTries");
Object.defineProperty(exports, "isTooManyTries", { enumerable: true, get: function () { return tooManyTries_1.isTooManyTries; } });

@@ -13,0 +13,0 @@ var utils_1 = require("./utils");

@@ -13,3 +13,3 @@ export type UNTIL<RETURN_TYPE> = (result: RETURN_TYPE) => boolean;

until?: UNTIL<RETURN_TYPE> | null;
onError?: (err: Error, currentTry: number) => void;
onError?: (err: Error, currentTry: number) => boolean | undefined;
onMaxRetryFunc?: (err: Error, currentTry: number) => void;

@@ -16,0 +16,0 @@ onSuccessFunc?: (result: RETURN_TYPE, currentTry: number) => void;

@@ -10,4 +10,4 @@ import { DELAY, RetryOptions, UNTIL } from "./options";

onSuccessFunc?: (result: RETURN_TYPE, currentTry: number) => void;
onError?: (err: Error, currentTry: number) => void;
onError?: (err: Error, currentTry: number) => boolean | undefined;
}
export declare function getRetryParameters<RETURN_TYPE>(currentTry: number, retryOptions?: RetryOptions<RETURN_TYPE>): Readonly<RetryParameters<RETURN_TYPE>>;

@@ -16,3 +16,4 @@ "use strict";

const parameters_1 = require("./parameters");
const tooManyTries_1 = require("./tooManyTries");
const abortError_1 = require("./utils/erros/abortError");
const tooManyTries_1 = require("./utils/erros/tooManyTries");
function retry(fn, retryOptions) {

@@ -33,2 +34,3 @@ return __awaiter(this, void 0, void 0, function* () {

function actualRetry(fn, retryParameters) {
var _a;
return __awaiter(this, void 0, void 0, function* () {

@@ -55,4 +57,5 @@ const canRecall = retryParameters.currentTry < retryParameters.maxTry;

if (!(0, tooManyTries_1.isTooManyTries)(err) && canRecall) {
if (retryParameters.onError) {
retryParameters.onError(err, retryParameters.currentTry);
const canRecall = (_a = retryParameters.onError) === null || _a === void 0 ? void 0 : _a.call(retryParameters, err, retryParameters.currentTry);
if (canRecall === false) {
throw new abortError_1.AbortError(err, retryParameters.currentTry);
}

@@ -59,0 +62,0 @@ return yield recall(fn, retryParameters);

export type { RetryOptions } from "./options";
export { getDefaultRetryOptions, setDefaultRetryOptions } from "./options";
export { retry, retryAsync } from "./retry";
export type { TooManyTries } from "./tooManyTries";
export { isTooManyTries } from "./tooManyTries";
export type { TooManyTries } from "./utils/erros/tooManyTries";
export { isTooManyTries } from "./utils/erros/tooManyTries";
export type { RetryUtilsOptions } from "./utils";
export { retryAsyncUntilDefined, retryAsyncUntilDefinedDecorator, retryAsyncUntilTruthy, retryAsyncUntilTruthyDecorator, retryUntilDefined, retryUntilDefinedDecorator, retryUntilTruthy, retryUntilTruthyDecorator, retryAsyncUntilResponse, retryAsyncUntilResponseDecorator, createExponetialDelay, createMutiplicableDelay, createRandomDelay, retryAsyncDecorator, retryDecorator, } from "./utils";
export { getDefaultRetryOptions, setDefaultRetryOptions } from "./options";
export { retry, retryAsync } from "./retry";
export { isTooManyTries } from "./tooManyTries";
export { isTooManyTries } from "./utils/erros/tooManyTries";
export { retryAsyncUntilDefined, retryAsyncUntilDefinedDecorator, retryAsyncUntilTruthy, retryAsyncUntilTruthyDecorator, retryUntilDefined, retryUntilDefinedDecorator, retryUntilTruthy, retryUntilTruthyDecorator, retryAsyncUntilResponse, retryAsyncUntilResponseDecorator, createExponetialDelay, createMutiplicableDelay, createRandomDelay, retryAsyncDecorator, retryDecorator, } from "./utils";

@@ -13,3 +13,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { getRetryParameters } from "./parameters";
import { isTooManyTries, TooManyTries } from "./tooManyTries";
import { isTooManyTries, TooManyTries } from "./utils/erros/tooManyTries";
export function retry(fn, retryOptions) {

@@ -16,0 +16,0 @@ return __awaiter(this, void 0, void 0, function* () {

{
"name": "ts-retry",
"version": "5.0.1",
"version": "6.0.0",
"main": "lib/cjs/index.js",

@@ -5,0 +5,0 @@ "module": "lib/esm/index.js",