I'm writing a userscript that needs to import/read from a large text file.
The text file is several GB in size, and if using split('\n') would create an array with millions as an array length.
You're going to say 'Oh but why do you need to process so much data'. I do need to, but I don't need to store it in an array. I accept that.
When running the userscript under firefox, it'll hang if the array that stores the text file has a length over about 50,000. That's fair enough.
Clearly I need a way to iterate over a large text file line by line ('\n') without actually storing the entire file in a string and then an array. I suspect Javascript isn't going to be great for this, but as this is a userscript I'm not sure what my other options are.
Not that my code really matters, but here's what I'm doing in a nutshell. This is a research project and nothing sinister. The below is more or less pseudo code.
var wordListString = GM_getResourceText("wordlist");
var wordListArray = wordListString.split('\n');
var username = "TestUsername";
$userField.val(username);
for (var i = 0; i < wordListArray.length; i++)
{
(function(o) {
setTimeout(function()
{
if ($userField.val() != username)
$userField.val(username);
$passwordField.val(wordListArray[o]);
setTimeout(function() {$loginButton.click()}, 50);
}, o * 1000);
})(i);
}