Socket
Socket
Sign inDemoInstall

promise-cache-retry

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    promise-cache-retry

[![NPM Version][npm-image]][npm-url] [![license][license-image]][license-url] [![GitHub Actions][github-image]][github-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![TypeScript Style Guide][gts-image]][gts-url] [![standard-readme compliant](http


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

promise-cache-retry

NPM Version license GitHub Actions Known Vulnerabilities TypeScript Style Guide standard-readme compliant

Table of Contents

Security

Background

If you simply cache the Promise it will always resolve with an error after an error occurs. On the other hand, retrying within a Promise will leave the Promise unresolved until the error is resolved, blocking further processing.

So this library works like this: If an error occurs, resolve it as an error, automatically perform retry processing (unless you disable it explicitly), and return the retry result when referencing the cache.

Install

npm install --save promise-cache-retry

Usage

import { PromiseCache } from 'promise-cache-retry';

const cache = new PromiseCache({
  promiseGenerator: async () => {
    const res = await fetchData(ENDPOINT);
    return res.data;
  },
  options: {
    maxRetries: 2,
    minRetryInterval: 3000,
  },
});

export const handler = async () => {
  const value = await cache.get();
}

Contributing

See the contributing file!

PRs accepted.

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © RICOH360

Keywords

FAQs

Last updated on 01 Nov 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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