Cannot pass ArrayBuffer or Uint8Array and get meaningful data back
WorkMAE opened this issue · 0 comments
Here is what I am trying to do...I have several binary files I am reading in, need to join them together ultimately and would like to use VKThreads for the processing of them.
However, I cannot get this to work. If I try and pass in the arrayBuffer data directly and put the line var data = new Uint8Array(dataArr)
in the runThread function, I get a return of an empty array. If I pass in the already converted Uint8Array as I have done, I get an error:
"Worker error: Uncaught TypeError: Cannot read property 'uint8array' of undefined at Worker.worker.onerror"
Is there any support for Transferrable Objects in vkThreads? If not is there any way to get this to work? I may have to use a normal webWorker if not it appears unfortunately...
var spawn = vkThread();
function runThread(dataArr) {
var workbook = XLSX.read(dataArr, { type: "array" });
var myJSON = XLSX.utils.sheet_to_json(workbook.Sheets.Sheet1);
return myJSON;
};
user.readBinary(CVData.path + num + '.xlsb').then(function (response) {
var data = new Uint8Array(response);
var param = {
fn: runThread,
args: [data],
importFiles: ['https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.0/xlsx.full.min.js']
};
spawn.exec(param).then(function (threadData) {
data.push(threadData);
}, function (err) {
alertify.error('There was an error running this thread! Error: ' + err);
});
});