Repository navigation
<
DCCE
/div>
Expand file tree
/
Copy pathworker.js
More file actions
46 lines (38 loc) · 949 Bytes
/
Copy pathworker.js
File metadata and controls
46 lines (38 loc) · 949 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
42
43
44
45
46
global.window = global;
function postConsole(level) {
var message = Array.prototype.slice.call(arguments, 1);
postMessage({
jsonrpc: '2.0',
method: 'console',
params: {
level: level,
message: message
}
});
}
self.console = {
log: postConsole.bind(self.console, 'log'),
warn: postConsole.bind(self.console, 'warn'),
error: postConsole.bind(self.console, 'error')
};
self.process = self.process || {};
var stream = require('stream');
process.stdout = new stream.Writable();
process.stdout._write = function (chunk, encoding, cb) {
var s = '';
for (var i = 0; i < chunk.length; i++) {
s += String.fromCharCode(chunk[i]);
}
console.log('stdout: ', s);
cb();
};
process.on = function () {
console.log('process.on called with:',
JSON.stringify(Array.prototype.slice.call(arguments)));
};
// set up runner
require('./worker-runner');
postMessage({
jsonrpc: '2.0',
method: 'ready'
});