title: How should I return data from fs.createReadStream() using csv parser
body: <p>I have this function</p>
  
  <pre><code>function getData(file, type) {
      let data = [];
      fs.createReadStream(file)
          .pipe(csv({headers: false, separator: ';',}))
          .on('data', (row) =&gt; {
              let item = {
                  date: row[0],
                  value: row[1]
              };
              let item2 = {
                  date: moment(row[0], "DD-MM-YYYY HH:mm").add(30, "minutes").format("DD/MM/YYYY HH:mm"),
                  value: row[2]
              };
              data.push(item);
              data.push(item2);
          })
          .on('end', () =&gt; {
             return data;
          });
  }
  </code></pre>
  
  <p>and I would like to return the data parsed in the csv, but when I return data in the <code>.on</code> method, data is empty.</p>
  
  <p>How should I do it ?</p>