Socket
Socket
Sign inDemoInstall

promise-retry

Package Overview
Dependencies
3
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.6 to 0.2.7

4

index.js

@@ -11,3 +11,3 @@ 'use strict';

return new Promise(function (resolve, reject) {
operation.attempt(function () {
operation.attempt(function (number) {
var promise;

@@ -24,3 +24,3 @@

});
});
}, number);
});

@@ -27,0 +27,0 @@

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

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

@@ -38,3 +38,5 @@ # node-promise-retry [![Build Status](https://travis-ci.org/IndigoUnited/node-promise-retry.svg?branch=master)](https://travis-ci.org/IndigoUnited/node-promise-retry)

// Simple example
promiseRetry(function (retry) {
promiseRetry(function (retry, number) {
console.log('attempt number', number);
return doSomething()

@@ -50,3 +52,5 @@ .catch(retry);

// Conditional example
promiseRetry(function (retry) {
promiseRetry(function (retry, number) {
console.log('attempt number', number);
return doSomething()

@@ -53,0 +57,0 @@ .catch(function (err) {

@@ -32,2 +32,27 @@ 'use strict';

it('should call fn with the attempt number', function (done) {
var count = 0;
promiseRetry(function (retry, number) {
count += 1;
expect(count).to.equal(number);
return Promise.delay(10)
.then(function () {
if (count <= 2) {
retry(new Error('foo'));
}
return 'final';
});
}, { factor: 1 })
.then(function (value) {
expect(value).to.be('final');
expect(count).to.be(3);
}, function () {
throw new Error('should not fail');
})
.done(done, done);
});
it('should not retry on fulfillment if retry was not called', function (done) {

@@ -34,0 +59,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