Skip to content
Subhajit Sahu edited this page Aug 1, 2022 · 1 revision

Sleep for specified time (async).

Alternatives: sleep, sleepSync.


function sleep(ms)
// ms: time in milliseconds

const {sleep} = require('extra-sleep');


async function main() {
  console.log('Turn on Alarm');
  // → Turn on Alarm

  await sleep(1000);
  console.log('Turn on Shower');
  // → Turn on Shower (after 1s)
}


References

Clone this wiki locally