-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransferable.js
More file actions
41 lines (33 loc) · 854 Bytes
/
Copy pathtransferable.js
File metadata and controls
41 lines (33 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
importScripts('shared.js');
var ready = false;
self.onmessage = function (e) {
if (!ready) {
initComplete();
return;
}
// Presumably, this worker would create its own Uint8Array or alter the
// ArrayBuffer (e.data) in some way. For this example, just send back the data
// we were sent.
var uInt8View = new Uint8Array(e.data);
console.log(uInt8View.length);
if (USE_TRANSFERABLE) {
self.postMessage(uInt8View.buffer, [uInt8View.buffer]);
} else {
self.postMessage(e.data);
}
};
self.onerror = function (message) {
log('worker error');
};
function log(msg) {
var object = {
type: 'debug',
msg: source() + msg + ' [' + time() + ']'
};
self.postMessage(object);
}
function initComplete() {
ready = true;
log('READY!');
}
//setupArray();