title: How to wait for all in Javascript
body: <p>My code is nearly working well my problem is that only the first CSV data is logged and the lambda function ends.</p>
  <p>I guess I need someway to wait for all <code>stream pipes</code> to end.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>myCsvList.forEach((myElem) =&gt; {
        const data = [];
  
        // setup params
  
        const csvFile = s3.getObject(params).createReadStream(); // works fine
  
        csvFile
          .pipe(csv())
          .on('data', function(entry) {
            data.push(entry);
          })
          .on('end', () =&gt; {
            console.log(data); // after the log of the first element on myCsvList, the code finishes. It should log all csvFiles from myCsvList
          });
  });</code></pre>
  </div>
  </div>
  </p>
  <p>I guess I need a promises or something?</p>