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"});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.3.5
    1
    • latest

Version History

Package Sidebar

Install

npm i safevm

Weekly Downloads

1

Version

1.3.5

License

MIT

Unpacked Size

4.24 kB

Total Files

4

Last publish

Collaborators

  • cryogena