title: Using "await" inside non-async function
body: <p>I have an async function that runs by a setInterval somewhere in my code. This function updates some cache in regular intervals.</p>
  
  <p>I also have a different, synchronous function which needs to retrieve values - preferably from the cache, yet if it's a cache-miss, then from the data origins 
  (I realize making IO operations in a synchronous manner is ill-advised, but lets assume this is required in this case).</p>
  
  <p>My problem is I'd like the synchronous function to be able to wait for a value from the async one, but it's not possible to use the <code>await</code> keyword inside a non-<code>async</code> function:</p>
  
  <pre><code>function syncFunc(key) {
      if (!(key in cache)) {
          await updateCacheForKey([key]);
      }
  }
  
  async function updateCacheForKey(keys) {
      // updates cache for given keys
      ...
  }
  </code></pre>
  
  <p>Now, this can be easily circumvented by extracting the logic inside <code>updateCacheForKey</code> into a new synchronous function, and calling this new function from both existing functions.</p>
  
  <p>My question is why absolutely prevent this use case in the first place? My only guess is that it has to do with "idiot-proofing", since in most cases, waiting on an async function from a synchronous one is wrong. But am I wrong to think it has its valid use cases at times?</p>
  
  <p>(I think this is possible in C# as well by using <code>Task.Wait</code>, though I might be confusing things here).</p>