Created
January 23, 2024 20:30
-
-
Save tgrecojs/a684b3529c52b4294517580a6944ceeb to your computer and use it in GitHub Desktop.
runme endojs example
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
#!/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)); |
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
{ | |
"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