@xapp/dynamo-service
Advanced tools
Comparing version 0.0.74 to 0.0.75
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -31,22 +23,25 @@ const Sleep_1 = require("./Sleep"); | ||
function backOff(props = {}, run, ...args) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let retries = 0; | ||
let sleepTime = 0; | ||
const realProps = Object.assign({ shouldRetry: alwaysTrue, retryAttempts: exports.DEFAULT_RETRY_ATTEMPTS, failOffStrategy: exponentialTime() }, props); | ||
const { retryAttempts, shouldRetry, failOffStrategy } = realProps; | ||
while (true) { | ||
try { | ||
return yield run(...args, retries); | ||
const realProps = Object.assign({ shouldRetry: alwaysTrue, retryAttempts: exports.DEFAULT_RETRY_ATTEMPTS, failOffStrategy: exponentialTime() }, props); | ||
const { retryAttempts, shouldRetry, failOffStrategy } = realProps; | ||
const attempt = (attempts = 0) => { | ||
let promise; | ||
try { | ||
promise = Promise.resolve(run(...args, attempts)); | ||
} | ||
catch (e) { | ||
promise = Promise.reject(e); | ||
} | ||
return promise | ||
.catch((e) => { | ||
if (attempts < retryAttempts && shouldRetry(e)) { | ||
const sleepTime = failOffStrategy(attempts); | ||
return Sleep_1.sleep(sleepTime) | ||
.then(() => attempt(++attempts)); | ||
} | ||
catch (e) { | ||
if (++retries < retryAttempts && shouldRetry(e)) { | ||
yield Sleep_1.sleep(sleepTime); | ||
sleepTime = failOffStrategy(retries); | ||
} | ||
else { | ||
throw e; | ||
} | ||
else { | ||
return Promise.reject(e); | ||
} | ||
} | ||
}); | ||
}); | ||
}; | ||
return attempt(1); | ||
} | ||
@@ -53,0 +48,0 @@ exports.backOff = backOff; |
{ | ||
"name": "@xapp/dynamo-service", | ||
"version": "0.0.74", | ||
"version": "0.0.75", | ||
"description": "A dynamo help class which will help maintain data integrity.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
144171
3880