@wmakeev/vm-sandbox
v0.1.0
Published
JavaScript code sandbox based on node.js vm module
Downloads
8
Maintainers
Readme
vm-sandbox
JavaScript code sandbox based on node.js
vm
module. Use for better testing and code isolation.
Inspired by metavm
Install
npm install @wmakeev/vm-sandbox
Using
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