Skip to content

Instantly share code, notes, and snippets.

@zhuixinjian
Forked from eteeselink/delay.js
Created June 30, 2020 07:00
Show Gist options
  • Select an option

  • Save zhuixinjian/c99ef4fe1a9483267a4f86512bf103d6 to your computer and use it in GitHub Desktop.

Select an option

Save zhuixinjian/c99ef4fe1a9483267a4f86512bf103d6 to your computer and use it in GitHub Desktop.
ES7 async/await version of setTimeout
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
async function something() {
console.log("this might take some time....");
await delay(5000);
console.log("done!")
}
something();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment