Unlisted
Back
Version 23
8/13/2024
import * as qjs from "https://cdn.jsdelivr.net/npm/quickjs-emscripten@0.29.2/dist/index.js";
console.log(qjs);
async function main() {
const QuickJS = await getQuickJS();
const vm = QuickJS.newContext();
const world = vm.newString("world");
vm.setProp(vm.global, "NAME", world);
world.dispose();
const result = vm.evalCode(`"Hello " + NAME + "!"`);
if (result.error) {
console.log("Execution failed:", vm.dump(result.error));
result.error.dispose();
} else {
console.log("Success:", vm.dump(result.value));
result.value.dispose();
}
vm.dispose();
}
main();
Updated: August 13, 2024