-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsandbox.js
42 lines (34 loc) · 1.06 KB
/
sandbox.js
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
// Generated by CoffeeScript 1.7.1
(function() {
var Sandbox, child_process;
child_process = require("child_process");
Sandbox = (function() {
function Sandbox(handler) {
this.handler = handler;
this.child = child_process.fork(__dirname + '/shovel.js');
this.timer = 0;
this.callback = this.handler;
this.child.on("message", (function(_this) {
return function(result) {
clearTimeout(_this.timer);
_this.callback(result);
return _this.callback = _this.handler;
};
})(this));
}
Sandbox.prototype["eval"] = function(code, callback) {
this.callback = callback;
this.child.send(code);
return this.timer = setTimeout(((function(_this) {
return function() {
_this.child.kill("SIGKILL");
_this.callback("TimeoutError: restarting repl...");
return _this.constructor.apply(_this);
};
})(this)), 10 * 1000);
};
return Sandbox;
})();
module.exports = Sandbox;
}).call(this);
//# sourceMappingURL=sandbox.map