Skip to content

Instantly share code, notes, and snippets.

@mrienstra
Last active March 5, 2025 08:48
Show Gist options
  • Select an option

  • Save mrienstra/8aa4eeeeab2012d2aa8ffc7f5e45f280 to your computer and use it in GitHub Desktop.

Select an option

Save mrienstra/8aa4eeeeab2012d2aa8ffc7f5e45f280 to your computer and use it in GitHub Desktop.

Revisions

  1. mrienstra revised this gist Apr 30, 2021. 1 changed file with 22 additions and 2 deletions.
    24 changes: 22 additions & 2 deletions verbose_await_promise.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,25 @@
    await new Promise(function (resolve) {
    setTimeout(function () {
    resolve();
    }, 1000));
    });
    }, 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));
  2. mrienstra renamed this gist Apr 30, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. mrienstra created this gist Apr 30, 2021.
    5 changes: 5 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    await new Promise(function (resolve) {
    setTimeout(function () {
    resolve();
    }, 1000));
    });