Skip to content

Instantly share code, notes, and snippets.

@ludndev
Forked from mrienstra/verbose_await_promise.js
Created March 5, 2025 08:43
Show Gist options
  • Select an option

  • Save ludndev/cef93d4966e2b17c867ec867a7737fb9 to your computer and use it in GitHub Desktop.

Select an option

Save ludndev/cef93d4966e2b17c867ec867a7737fb9 to your computer and use it in GitHub Desktop.
await new Promise(function (resolve) {
setTimeout(function () {
resolve();
}, 1000);
});
// ... Can be shortened to:
await new Promise(function (resolve) {
setTimeout(resolve, 1000);
});
// ... Can be shortened to:
await new Promise((resolve) => {
setTimeout(resolve, 1000);
});
// ... Can be shortened to:
await new Promise((resolve) => setTimeout(resolve, 1000));
// ... Can be shortened to:
await new Promise(resolve => setTimeout(resolve, 1000));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment