Socket
Socket
Sign inDemoInstall

promise-retry

Package Overview
Dependencies
3
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.7 to 0.2.8

16

index.js

@@ -7,2 +7,8 @@ 'use strict';

var hasOwn = Object.prototype.hasOwnProperty;
function isRetryError(err) {
return err && err.code === 'EPROMISERETRY' && hasOwn.call(err, 'retried');
}
function promiseRetry(fn, options) {

@@ -17,8 +23,8 @@ var operation = retry.operation(options);

return fn(function (err) {
if (err && err.code === 'EPROMISERETRY') {
err = err.original;
if (isRetryError(err)) {
err = err.retried;
}
throw errcode('Retrying', 'EPROMISERETRY', {
original: err
retried: err
});

@@ -29,4 +35,4 @@ }, number);

promise.done(resolve, function (err) {
if (err && err.code === 'EPROMISERETRY') {
err = err.original;
if (isRetryError(err)) {
err = err.retried;

@@ -33,0 +39,0 @@ if (operation.retry(err || new Error())) {

{
"name": "promise-retry",
"version": "0.2.7",
"version": "0.2.8",
"description": "Retries a function that returns a promise, leveraging the power of the retry module.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -93,2 +93,21 @@ 'use strict';

it('should not retry on rejection if nr of retries is 0', function (done) {
var count = 0;
promiseRetry(function (retry) {
count += 1;
return Promise.delay(10)
.thenThrow(new Error('foo'))
.catch(retry);
}, { retries : 0 })
.then(function () {
throw new Error('should not succeed');
}, function (err) {
expect(err.message).to.be('foo');
expect(count).to.be(1);
})
.done(done, done);
});
it('should reject the promise if the retries were exceeded', function (done) {

@@ -95,0 +114,0 @@ var count = 0;

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc