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

1.0.2 • Public • Published

Retry Machine

Retry Promises

const { retry } = require('retry-machine');

async function run(count) {
  console.log(count);
}

async function failure(e, attempt) {
  console.error(e);
}

const runner = retry({ max: 5, delay: 1000, factor: 2 }, failure);
await runner(run, 1);

Optionally pass in a logger:

const { retry } = require('retry-machine');
const logger = require('./logger');

async function run(count) {
  console.log(count);
}

async function failure(e, attempt) {
  console.error(e);
}

const runner = retry({ max: 5, delay: 1000, factor: 2, logger }, failure);
await runner(run, 1);

Readme

Keywords

none

Package Sidebar

Install

npm i retry-machine

Weekly Downloads

412

Version

1.0.2

License

Apache-2.0

Unpacked Size

7.24 kB

Total Files

10

Last publish

Collaborators

  • johndagostino
  • ordermentumeng