I get a buffer (and I can make it a string) from child_process.exec()
开发者_JAVA技巧 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;
}
精彩评论