問題:
I would like to read a very, very large file into a JavaScript array in node.js.我想將一個非常非常大的文件讀入 node.js 中的 JavaScript 數組。
So, if the file is like this:所以,如果文件是這樣的:
first line
two
three
...
...
I would have the array:我會有數組:
['first line','two','three', ... , ... ]
The function would look like this:該函數如下所示:
var array = load(filename);
Therefore the idea of loading it all as a string and then splitting it is not acceptable.因此,將其全部加載爲字符串然後將其拆分的想法是不可接受的。
解決方案:
參考一: https://en.stackoom.com/question/SfIE參考二: https://stackoom.com/question/SfIE