Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-fetch-retry

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-fetch-retry - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

5

index.js

@@ -5,3 +5,2 @@ const fetch = require('node-fetch');

let retry = opts && opts.retry || 3
let pause = (opts && opts.pause && opts.pause > 0) || 0

@@ -21,5 +20,5 @@ while (retry > 0) {

if (opts.pause) {
console.log("pausing..");
if (!opts.silent) console.log("pausing..");
await sleep(opts.pause);
console.log("done pausing...");
if (!opts.silent) console.log("done pausing...");
}

@@ -26,0 +25,0 @@ }

2

package.json
{
"name": "node-fetch-retry",
"version": "1.1.0",
"version": "1.1.1",
"description": "Retry library for node-fetch",

@@ -5,0 +5,0 @@ "scripts": {

@@ -47,2 +47,12 @@ # node-fetch-retry [![npm version](https://img.shields.io/npm/v/node-fetch-retry.svg?style=flat)](https://www.npmjs.com/package/node-fetch-retry) [![NPM](https://img.shields.io/npm/dt/node-fetch-retry.svg?style=flat-square&colorB=fd7463)](https://www.npmjs.com/package/node-fetch-retry) <a href="https://travis-ci.org/greatjapa/node-fetch-retry"><img alt="Travis Status" src="https://travis-ci.org/greatjapa/node-fetch-retry.svg?branch=master"></a> [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/greatjapa/node-fetch-retry/blob/master/LICENSE)

let res = await fetch('https://google.com', opts)
```
If you would like to silence pause messages in your console include a silent boolean in your options.
```javascript
let opts = {
method: 'GET',
retry: 3,
pause: 1000,
silent: true
}
```

@@ -69,3 +69,3 @@ require('should');

it('should work properly with pause', async function () {
it('should work properly with pause and silent', async function () {
this.timeout(10000);

@@ -79,4 +79,33 @@

calls.push(new Date().getTime())
},
silent: true
}
let cntr = 0;
console.log = () => {
cntr++;
}
try {
await fetch('https://fakeURLfake', opts)
} catch (e) {
should.equal(true, calls[1] - calls[0] >= 1000);
should.equal(true, calls[2] - calls[1] >= 1000);
}
should.equal(cntr, 0);
});
it('should work properly with pause and not silent', async function () {
this.timeout(10000);
let calls = []
let opts = {
retry: 3,
pause: 1000, // in milliseconds
callback: retry => {
calls.push(new Date().getTime())
}
}
let cntr = 0;
console.log = (message) => {
cntr++;
}
try {

@@ -88,3 +117,4 @@ await fetch('https://fakeURLfake', opts)

}
should.equal(cntr, 4);
});
})
})
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