package
Returns a Promise that resolves with a given value after a set amount of time
npm install pdelayGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
128.7 kB
Includes dependencies.
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.
Both TypeScript and Flow type definitions for this module are included! The type definitions won't require any configuration to use.