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.8 to 0.2.9

12

index.js

@@ -14,4 +14,14 @@ 'use strict';

function promiseRetry(fn, options) {
var operation = retry.operation(options);
var temp;
var operation;
if (typeof fn === 'object' && typeof options === 'function') {
// Swap options and fn when using alternate signature (options, fn)
temp = options;
options = fn;
fn = temp;
}
operation = retry.operation(options);
return new Promise(function (resolve, reject) {

@@ -18,0 +28,0 @@ operation.attempt(function (number) {

2

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

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

@@ -33,3 +33,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)

If you prefer, you can pass the options first using the alternative function signature `promiseRetry([options], fn)`.
## Example
```js

@@ -36,0 +38,0 @@ var promiseRetry = require('promise-retry');

@@ -245,2 +245,24 @@ 'use strict';

});
it('should allow options to be passed first', function (done) {
var count = 0;
promiseRetry({ factor: 1 }, function (retry) {
count += 1;
return Promise.delay(10)
.then(function () {
if (count <= 2) {
retry(new Error('foo'));
}
return 'final';
});
}).then(function (value) {
expect(value).to.be('final');
expect(count).to.be(3);
}, function () {
throw new Error('should not fail');
}).done(done, done);
});
});
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