title: new Promise() vs (async () => {})()
body: <p>Block 1:</p>
  
  <pre><code>const promise = new Promise((resolve) =&gt; {
    setTimeout(resolve, 100);
  });
  </code></pre>
  
  <p>Block 2:</p>
  
  <pre><code>const promise = (async () =&gt; {
    await new Promise(resolve =&gt; {
      setTimeout(resolve, 100);
    });
  })();
  </code></pre>
  
  <p>Are the above two blocks equivalent? Any note-worthy differences?</p>
  
  <p>I know it's a highly contrived example and there's not much purpose for Block 2 here. But a situation I have is where I want to create and store a reference to a promise, but the promise executor function needs to use await to get some data. But declaring <code>new Promise(async (resolve) =&gt; {});</code> is considered an anti-pattern. Is block 2 in this situation any better?</p>
  
  <p>UPDATE: Providing a more concrete example of what I'm trying to do:</p>
  
  <pre><code>  export async function getData(request) {
      // De-dupe fetches for the same request and return existing promise.
      if (map.has(JSON.stringify(request))) {
        return map.get(JSON.stringify(request));
      }
  
      const thePromise = (async () =&gt; {
        const [foo, bar] = Promise.all(await getFoo(), await getBar());
  
        const theData = await getTheData(foo, bar);
  
        return theData.some.thing ? 'a' : 'b';
      })();
  
      map.put(JSON.stringify(request), thePromise);
      return thePromise;
    }
  </code></pre>