summaryrefslogtreecommitdiffstats
path: root/dom/workers/test/fileReadSlice_worker.js
blob: 2c10b7d7633e1b3ed4b945ba5d810f6b9da13d33 (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);
};