I get a buffer (and I can make it a string) from child_process.exec()
in NodeJS. I need to iterate over the lines of the output string. How would I do this?
One way to avoid splitting the whole thing in memory is to process it one line at a time
var i = 0;
while (i < output.length)
{
var j = output.indexOf("\\n", i);
if (j == -1) j = output.length;
.... process output.substr(i, j-i) ....
i = j+1;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With