Skip to content

Instantly share code, notes, and snippets.

@faneder
Created June 1, 2018 21:13
Show Gist options
  • Save faneder/5e5d78d5e0a828177442a81626768785 to your computer and use it in GitHub Desktop.
Save faneder/5e5d78d5e0a828177442a81626768785 to your computer and use it in GitHub Desktop.
ES7 async/await of setTimeOut
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const delay = async (time) => {
console.log(`please wait ${time}.....`);
await sleep(time);
console.log("done~ all good!!")
}
delay(5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment