Miss any of our Open RFC calls?Watch the recordings here! »

safevm

1.3.5 • Public • Published

Safe secure Sandboxed VM for code.

    const safevm = require('safevm');

    result = safevm( // result is the module.exports
        function () {
            output("test");
        },
            // string or function of code to be run safely
        [{ output: console.log }],
            // array of context/globals, default use is the first or a new object
        { filename: "" }
            // Options from https://nodejs.org/api/vm.html#vm_vm_runinnewcontext_code_sandbox_options with a few added options like dirname, globalIndex, onError, etc.
    );

    result = safevm(require("fs").readFileSync("path/to/file.js"), {}, { filename: "vm.js"});

Install

npm i safevm

DownloadsWeekly Downloads

2

Version

1.3.5

License

MIT

Unpacked Size

4.24 kB

Total Files

4

Last publish

Collaborators

  • avatar