fix portability of sandbox.run_code() on Node.js 0.1x (#2078)

This commit is contained in:
Alex Lam S.L
2017-06-10 01:08:58 +08:00
committed by GitHub
parent 9186859cb7
commit 4ad7b1dae4
2 changed files with 18 additions and 1 deletions

View File

@@ -52,7 +52,10 @@ exports.run_code = function(code) {
"}();",
].join("\n"), {
console: {
log: function() {
log: function(msg) {
if (arguments.length == 1 && typeof msg == "string") {
return console.log("%s", msg);
}
return console.log.apply(console, [].map.call(arguments, function(arg) {
return safe_log(arg, 3);
}));