How to write to a writer stream every 5 seconds or when the writer stream buffer is full?
I need to write a Node.js app that continuously reads data from a reader stream and writes the data to a writer stream. The details of the reader stream are not importance. However, there are some requirements that the app and write stream must satisfy.
1- if the buffer in the writer stream is full, then the writer stream is flushed
2- if the bugger is not full every 5 seconds, the the writer stream is also flushed.
So the writer stream is flushed either if it is full or every 5 seconds, which ever comes first.
How would I write something like this?
Thanks
Read more here: Source link
