Socket
Socket
Sign inDemoInstall

retry-promise-func

Package Overview
Dependencies
11
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    retry-promise-func

retry-promise-func是一个用于在失败时重试Promise调用的工具。


Version published
Maintainers
1
Created

Readme

Source

retry-promise-func

retry-promise-func 是一个用于在失败时重试 Promise 调用的工具。

安装

使用 npm 安装: npm install retry-promise-func

使用 yarn 安装: yarn add retry-promise-func

使用

使用方法非常简单。只需导入 retry 函数并调用它即可:

import { retry } from "retry-promise-func";

const someFunction = async (someParams) => {
  return new Promise((resolve, reject) => {
    console.log(someParams);
    setTimeout(() => {
      if (Math.random() > 0.5) {
        resolve("Success");
      } else {
        reject("Failure");
      }
    }, 1000);
  });
};

const main = async () => {
  try {
    const result = await retry(someFunction, { a: 1 }, 10, 2000);
    console.log(result);
  } catch (error) {
    console.log(error);
  }
};

main();

Keywords

FAQs

Last updated on 17 Feb 2023

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