pdelay
pdelay(time, value)
This function returns a promise that resolves with a given value (optional) after a set amount of time (in milliseconds).
import pdelay from 'pdelay';
async function doStuff() {
console.log('about to wait one second...');
await pdelay(1000);
console.log('done waiting');
}
pdelay(2000, 'two seconds later').then(value => {
console.log('got value', value);
});
The value parameter may be omitted, and the Promise will resolve to
undefined
.
Types
Both TypeScript and Flow type definitions for this module are included! The type definitions won't require any configuration to use.