@skidding/async-retry
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

async-retry

ci status coverage status

Wait until cb doesn't throw or time out.

Install @skidding/async-retry.

Why not zeit/async-retry?

I use this package for testing async behavior where running times are sensitive. What's different here?

  • No exponential backoff strategy
  • Callback is ran immediately
  • Default loop interval is minimal
  • Default timeout is less than a usual test timeout

These settings minimize the time spent waiting and don't require custom options in most cases. They work for tests because assertion execution is usually cheap (I think ¯\_(ツ)_/¯).

Usage

retry(callback: Function, options: Object): Promise

See async-until for available options.

await retry(() => {
  expect(onChange).toHaveBeenCalledWith({ count: 3 });
});

Readme

Keywords

none

Package Sidebar

Install

npm i @skidding/async-retry

Weekly Downloads

16

Version

4.0.0

License

MIT

Unpacked Size

3.83 kB

Total Files

5

Last publish

Collaborators

  • skidding