-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshovel.js
More file actions
84 lines (79 loc) · 2.22 KB
/
shovel.js
File metadata and controls
84 lines (79 loc) · 2.22 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Generated by CoffeeScript 1.7.1
(function() {
var util, vm,
__slice = [].slice;
util = require("util");
vm = require("vm");
({
isEvaluating: false,
logs: [],
init: function() {
var sandbox;
sandbox = this.createSandbox();
return process.on("message", (function(_this) {
return function(data) {
var err;
_this.isEvaluating = true;
try {
_this.logs.push(util.inspect(vm.runInNewContext(data, sandbox)));
} catch (_error) {
err = _error;
_this.logs.push(err.stack);
}
process.send(_this.logs.join("\n"));
_this.logs = [];
return _this.isEvaluating = false;
};
})(this));
},
createSandbox: function() {
var env, tids;
tids = [];
env = {
_: require("underscore"),
ls: require("prelude-ls"),
async: require("async"),
CoffeeScript: require("coffee-script"),
setTimeout: function() {
var args, callback, delay;
callback = arguments[0], delay = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
if (delay == null) {
delay = 1000;
}
if (delay < 1000) {
delay = 1000;
}
tids.push(setTimeout.apply(null, [callback, delay].concat(args)));
return tids[tids.length - 1];
},
clearTimeout: clearTimeout,
getTimeouts: function() {
return tids.slice(0);
},
console: {
log: (function(_this) {
return function() {
var str;
str = Array.prototype.map.call(arguments, function(v) {
if (typeof v === "string") {
return v;
} else {
return util.inspect(v);
}
}).join(", ");
if (_this.isEvaluating) {
_this.logs.push(str);
} else {
process.send(str);
}
return void 0;
};
})(this)
}
};
env.global = env;
return env;
}
}).init();
}).call(this);
//# sourceMappingURL=shovel.map