https://github.com/wmakeev/vm-sandbox
JavaScript code sandbox based on node.js `vm` module
https://github.com/wmakeev/vm-sandbox
isolation metavm sandbox testing vm
Last synced: 3 months ago
JSON representation
JavaScript code sandbox based on node.js `vm` module
- Host: GitHub
- URL: https://github.com/wmakeev/vm-sandbox
- Owner: wmakeev
- Created: 2022-01-18T08:57:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-18T09:25:52.000Z (over 4 years ago)
- Last Synced: 2025-08-09T00:33:13.336Z (11 months ago)
- Topics: isolation, metavm, sandbox, testing, vm
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# vm-sandbox
[](https://www.npmjs.com/package/@wmakeev/vm-sandbox)
> JavaScript code sandbox based on node.js `vm` module. Use for better testing and code isolation.
Inspired by [metavm](https://github.com/metarhia/metavm)
## Install
```bash
npm install @wmakeev/vm-sandbox
```
## Using
```js
const src = `
const { mult, round } = api
const radius = 12
const s = round(mult(mult(2, PI), radius))
s
`
const script = createScript('myScript', src, {
context: {
api: {
mult: (a, b) => a * b,
round: Math.round
},
PI: Math.PI
}
})
console.log(script.exports) // 75
```