stevenbeales
12/27/2018 - 3:23 AM

sleep

Sleep function in JS w/ promises

const sleep = (ms) =>
  new Promise(resolve => setTimeout(resolve, ms));

const main = async () => {
  console.log('Going to sleep...');
  await sleep(2000);
  console.log('...and we\'re back!');
}

main();