title: dealing with asynchronous updating of an object
body: <pre><code>const globalObject = {};
  const varAList = [.....];
  const varBList = [.....];
  const varA = await Promise.all(
      varAList.map(
          async (aObject) =&gt; {
              const toReturn = [];
              for (const bObject of varBList) {
                  if (!globalObject[bObject.id]) {
                      console.log(`getting ${bObject.id}`);
                      globalObject[bObject.id] = await getObject(bObject.id);
                  }
                  if (globalObject[bObject.id].important == true){
                      toReturn.push(globalObject[bObject.id].something)
                  }
              }
              return {aObject.id: toReturn}
          }
      )
  );
  </code></pre>
  <p>The problem with this code is that the line <code>console.log(``getting ${bObject.id}``)</code> will be repeated for the same id since the <code>varAList</code> is going in parallel. How do I make sure that I am asynchronously checking this object and not remaking a request if it already exists?
  Any solutions?</p>