title: Best way to write events to a file coming from kafka
body: <p>I'm creating a nodejs library that reads events from kafka and pushes them into a file. The plan is to push data until the file reaches, for example, 100MB (or 2000 events). My questions are:</p>
  <ul>
  <li>Is there already a library that does this?</li>
  <li>If there isn't, I was thinking about doing the following:</li>
  </ul>
  <p>1 - Read the event from kafka and transform it.<br />
  2 - Push the data into an array.<br />
  3 - Have a second thread reading from that array and pushing it to the file using writeStream.</p>
  <p>Is there a better option?</p>
  <p>Thanks,<br />
  Luís</p>