Created
July 24, 2023 15:36
-
-
Save humphd/2168e398b6ba83d3fe579f63f429ef13 to your computer and use it in GitHub Desktop.
CharCraft JS Runtime function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const name = "runJS"; | |
export const description = "Runs arbitrary JavaScript code in a browser context (no node.js)"; | |
export const parameters = { | |
type: "object", | |
properties: { | |
"code": { | |
type: "string", | |
description: "JavaScript code to run in browser", | |
} | |
} | |
}; | |
export default async function (data) { | |
const { code } = data; | |
let result; | |
try { | |
result = eval(code); | |
} catch (error) { | |
result = error.toString(); | |
} | |
return result.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment