2.0.0 • Published 6 years ago

pdelay v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

pdelay

GitHub license npm version CircleCI Status Greenkeeper badge

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.