1
0
Fork 0
firefox/dom/workers/test/fileReadSlice_worker.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

16 lines
422 B
JavaScript

/**
* Expects an object containing a blob, a start index and an end index
* for slicing. Returns the contents of the blob read as text.
*/
onmessage = function (event) {
var blob = event.data.blob;
var start = event.data.start;
var end = event.data.end;
var slicedBlob = blob.slice(start, end);
var fileReader = new FileReaderSync();
var text = fileReader.readAsText(slicedBlob);
postMessage(text);
};