heartbeat-retry
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

heartbeat-retry

NPM TypeScript

Retry a promise with a heartbeat.

If I should maintain this repo, please ⭐️ GitHub stars

DM me on Twitter if you have questions or suggestions. Twitter


NPM
npm install heartbeat-retry
Yarn
yarn add heartbeat-retry
PNPM
pnpm add heartbeat-retry
Bun
bun add heartbeat-retry

Usage

heartbeat-retry is built on p-retry, so it exposes the same options, in addition to heartbeat and onHeartbeat:

import retry from "heartbeat-retry";

retry(promise, {
  heartbeat: 10_000, // 10 seconds
  onHeartbeat: (elapsed: number) => {
    console.log("Heartbeat")
  },
  retries: 5,
  onFailedAttempt: (error) => {
    console.log("Failed attempt", error);
  }
});

Dependenciesdependencies

  • p-retry: Retry a promise-returning or async function

Dev Dependencies


License license

MIT

Package Sidebar

Install

npm i heartbeat-retry

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

5.81 kB

Total Files

4

Last publish

Collaborators

  • bconnorwhite