exports.handler = async function(event, context) {
const console = {
_items: [],
log: function () {
console._items.push.apply(console._items, Array.from(arguments).map(e => JSON.stringify(e)));
}
};
console.error = console.info = console.debug = console.log;
let result = exec(event.code);
let stdOut = console._items.reduce((l, r) => l + "\r\n" + r);
if (stdOut === "")
return {result};
else
return {result: `Result: ${result}\r\nOutput\r\n${stdOut}`};