问题:
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