@trenskow/wait

1.3.19 • Public • Published

@trenskow/wait

A promisified version of setTimeout.

Usage

const wait = require('@trenskow/wait');

await wait('2s');

Waits two seconds.

Time Interval Format

Internally it uses the ms package – see that package for documentation.

Cancelling

You can also cancel the wait before the specified time.

const waiter = wait('2s');

setTimeout(waiter.cancel, 1000);

await waiter;

/* returns after one second instead of two because `setTimeout` triggers the elapse function of `waiter`. */

License

MIT (see license)

Package Sidebar

Install

npm i @trenskow/wait

Weekly Downloads

2

Version

1.3.19

License

MIT

Unpacked Size

6.49 kB

Total Files

7

Last publish

Collaborators

  • trenskow