retry-machine

Retry Promises

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
retry-machine
1.0.2a year ago6 years agoMinified + gzip package size for retry-machine in KB

Readme

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);