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

async-retry

Package Overview
Dependencies
Maintainers
15
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-retry - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

LICENSE.md

54

lib/index.js
// Packages
const retrier = require('retry')
var retrier = require('retry');
module.exports = (fn, opts) => {
opts = opts || {}
function retry(fn, opts) {
function run(resolve, reject) {
var options = opts || {};
var op = retrier.operation(options);
return new Promise((resolve, reject) => {
const op = retrier.operation(opts)
// We allow the user to abort retrying

@@ -14,30 +13,43 @@ // this makes sense in the cases where

// would be futile (e.g.: auth errors)
const bail = err => reject(err || new Error('Aborted'))
const onError = (err, num) => {
function bail(err) {
reject(err || new Error('Aborted'));
}
function onError(err, num) {
if (err.bail) {
return bail(err)
bail(err);
return;
}
if (!op.retry(err)) {
reject(op.mainError())
} else if (opts.onRetry) {
opts.onRetry(err, num)
reject(op.mainError());
} else if (options.onRetry) {
options.onRetry(err, num);
}
}
op.attempt(num => {
let val
function runAttempt(num) {
var val;
try {
val = fn(bail, num)
val = fn(bail, num);
} catch (err) {
return onError(err, num)
onError(err, num);
return;
}
Promise.resolve(val)
.then(resolve)
.catch(err => {
onError(err, num)
})
})
})
.catch(function catchIt(err) {
onError(err, num);
});
}
op.attempt(runAttempt);
}
return new Promise(run);
}
module.exports = retry;
{
"name": "async-retry",
"version": "1.2.1",
"version": "1.2.2",
"description": "Retrying made simple, easy and async",
"main": "./lib/index.js",
"scripts": {
"test": "xo && ava"
"test": "yarn run test-lint && yarn run test-unit",
"test-lint": "eslint .",
"test-unit": "ava",
"lint:staged": "lint-staged"
},
"files": [
"lib"
],
"license": "MIT",

@@ -14,19 +20,37 @@ "repository": "zeit/async-retry",

},
"xo": {
"esnext": true,
"space": true,
"semicolon": false,
"ignores": [
"examples/**/*"
"dependencies": {
"retry": "0.12.0"
},
"pre-commit": "lint:staged",
"lint-staged": {
"*.js": [
"eslint",
"prettier --write --single-quote",
"git add"
]
},
"dependencies": {
"retry": "0.10.1"
"eslintConfig": {
"extends": [
"airbnb",
"prettier"
],
"rules": {
"no-var": 0,
"prefer-arrow-callback": 0
}
},
"devDependencies": {
"ava": "0.25.0",
"node-fetch": "2.0.0",
"then-sleep": "1.0.1",
"xo": "0.20.3"
"eslint": "5.5.0",
"eslint-config-airbnb": "17.1.0",
"eslint-config-prettier": "3.0.1",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsx-a11y": "6.1.1",
"eslint-plugin-react": "7.11.1",
"lint-staged": "7.2.2",
"node-fetch": "2.2.0",
"pre-commit": "1.2.2",
"prettier": "1.14.2",
"then-sleep": "1.0.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc