I'm trying to split the content of a file into chunks of a certain size (say 40000 characters including whitespaces and what-not)
But what I have splits the array when there's a line change as well, which is unwanted behavior.
var files = $('#upload').get(0).files;
if (files.length > 0) {
var reader = new FileReader()
reader.onloadend = function () {
var content = reader.result
var buffer = 40000
var contentList = content.match(new RegExp('.{1,' + buffer + '}', 'gm'))
console.info('list : ', contentList)
}
reader.readAsBinaryString(files[0])
}
A an extra question, I can see that there's no indications of a new line in the file been read, although there's clearly multiple lines in the file. I'm missing something like \n
once in a while.