0.0.3 • Published 6 years ago

async-repeat v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

async repeat

Table of Contents

About

Repeat function with async.

Install

npm install async-repeat

Usage

// CommonJS
// const axiosRetry = require('async-repeat');

// ES6
import asyncRepeat from "async-repeat";

(async () => {
  await asyncRepeat(
    async done => {
      try {
        const res = await rp("http://www.google.com");
        done();
      } catch (e) {
        // Do nothing, repeat.
      }
    },
    {
      delay: 1000, // default 3000
      maxCount: 5, // default 10
    },
  );
})();

API

asyncRepeat(retrier: Function, options: Object) => Promise

Retrier

  • The supplied function receives two parameters:
    • done: Resolve repeat function.
    • utils: Utilities for repeat function.
      • utils.checkCount: Repeat count.
      • utils.reject: Reject the repeat function.
      • utils.resovle: Resolve the repeat function, it same done.

Options

NameTypeDefaultDescription
delaynumber3000Repeat interval (ms).
maxCountnumber10Maximum repeat times.
defaultResultanynullReturn value when the maximum number of times is exceeded.

Testing

Clone the repository and execute:

npm test

Contribute

Open an issue or submit PRs.

License

MIT.

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago