Gathering detailed insights and metrics for @pdedg/promise-retry
Gathering detailed insights and metrics for @pdedg/promise-retry
Gathering detailed insights and metrics for @pdedg/promise-retry
Gathering detailed insights and metrics for @pdedg/promise-retry
npm install @pdedg/promise-retry
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1 Stars
9 Commits
5 Branches
1 Contributors
Updated on 14 Aug 2019
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
0%
3
Compared to previous day
Last week
75%
7
Compared to previous week
Last month
20%
36
Compared to previous month
Last year
-81.7%
479
Compared to previous year
promise-retry A promise retry executor with exponential backoff strategy. Comes with fetch retry out of the box
Install the package:
1npm i @pdedg/promise-retry
A promise retry executor
1// Simple execution 2 3import { promiseRetry } from '@pdedg/promise-retry'; 4 5const run = () => new Promise((resolve, reject) => reject()); 6promiseRetry(run); // will execute rejected promise by default 3 times and after will trow error
1// With custom delay strategy 2 3import { promiseRetry } from '@pdedg/promise-retry'; 4 5const options = { 6 retries: 5, 7 retryOn: (err) => true, 8 delay: (err) => err.attempt * 1000, 9 onFailedAttempt: (err) => console.log(err.status) 10} 11 12const run = () => new Promise((resolve, reject) => reject()); 13promiseRetry(run); 14/* 15 Will result of: 5 executions of failed promise ( retryOn is set to all ways true ). 16 On each attempt it will execute the onFailedAttempt, and will use linear delay between executions ( last will be 5s delay ) 17 */
Wraps a fetch request with retry, by default it will retry on the following http status [408, 503, 504] and on request-timeout error.
1// Simple execution 2 3import { fetchRetry } from '@pdedg/promise-retry'; 4 5const fetch = () => new Promise((resolve, reject) => reject()); 6fetchRetry(fetch, '/end-point', { delay: 100 }); // Will execute 3 fetch calls with 100 / 200 / 400 delay and eventually an error will be thrown.
1// With custom options 2 3import { fetchRetry } from '@pdedg/promise-retry'; 4 5const options = { 6 retries: 2, 7 retryOnResolved: (res) => { 8 if (res.status === 300) { 9 throw new Error('Cannot handle 300 status.') 10 } 11 }, 12} 13 14const fetch = () => new Promise((resolve, reject) => resolve({ status: 300 })); 15fetchRetry(fetch, '/end-point', options) 16/* 17 Will result of: 2 executions of resolved promises, that will be rejected by the validate resolved method. 18 eventually, it will throw an error. 19 */
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/9 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
65 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More