Skip to content

Instantly share code, notes, and snippets.

@tgrecojs
Created January 23, 2024 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgrecojs/a684b3529c52b4294517580a6944ceeb to your computer and use it in GitHub Desktop.
Save tgrecojs/a684b3529c52b4294517580a6944ceeb to your computer and use it in GitHub Desktop.
runme endojs example
#!/usr/bin/env node
import "@endo/init";
const isFrozen = o => Object.isFrozen(o);
const mathCompartment = new Compartment({ Math, print: console.log });
mathCompartment.evaluate(`
const result = Math.pow(2, 5);
print('2 to the 5th power is:::', result);
`);
console.log(mathCompartment.globalThis === Compartment.globalThis);
console.log('Frozen globals check', [Array.prototype, Object.prototype].map(isFrozen));
{
"name": "runme-endo-demo",
"version": "1.0.0",
"bin": "./index.js",
"type": "module",
"scripts": {
"start": "node ./index.js"
},
"devDependencies": {
"@endo/init": "^0.5.60"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment