Skip to content

trenskow/wait

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A promisified version of `setTimeout`.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published