Async Func | sleep

PHOTO EMBED

Wed Apr 06 2022 18:43:25 GMT+0000 (Coordinated Universal Time)

Saved by @massa

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

async function sleepyWork() {
  console.log("I'm going to sleep for 1 second.");
  await sleep(1000);
  console.log('I woke up after 1 second.');
}
content_copyCOPY

Delays the execution of an asynchronous function. Delay executing part of an async function, by putting it to sleep, returning a Promise.

https://30secondsofknowledge.com/