summaryrefslogtreecommitdiffstats
path: root/dom/workers/test/fileReadSlice_worker.js
blob: edbad888028bd34b0f43c06b59aae1348749e2d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
 * 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);
};