We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const assert = require('assert') const {default: Safeify} = require("safeify"); async function sandboxFn(context, script) { // 创建 safeify 实例 const safeVm = new Safeify({ timeout: 3000, asyncTimeout: 60000 }) // 执行动态代码 const result = await safeVm.run(script, context) // 释放资源 safeVm.destroy() return result } const context = { a: 1, b: 2, c:1, add(a, b) { return a + b; }, assert: assert }; sandboxFn(context,`return assert.equal(a, c)`).then(res=>{ console.log('result',res); }).catch(err=>{ console.log(err) })
node version: 14.17
safeify version: 5.0.5
The text was updated successfully, but these errors were encountered:
https://mdnice.com/writing/c1a82b5817934d2fad3dbf8aaae93aee
Sorry, something went wrong.
No branches or pull requests
node version: 14.17
safeify version: 5.0.5
The text was updated successfully, but these errors were encountered: