/await-sleep

sleep=s=>new Promise(r=>setTimeout(r,1e3*s)) // await sleep(1)

Primary LanguageJavaScript

await-sleep

Simple sleep with async/await

Installation

npm install --save await-sleep

Usage

import sleep from 'await-sleep'

async function myAsyncFunction() {
  console.time('Sleeping');

  await sleep(1500);

  console.timeEnd('Sleeping'); // Sleeping: 1507.180ms
}