Macil / pdelay

Javascript function that returns a promise that resolves after some time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Javascript function that returns a promise that resolves after some time

License:MIT License


Languages

Language:JavaScript 92.0%Language:TypeScript 8.0%