mwg API
    Preparing search index...

    Function createPyroeisScriptHost

    • Optional Lua 5.4 host. Pyroeis is loaded only by this subpath, never by mwg/mwl.

      Sandboxed for untrusted scripts: only the base, coroutine, math, string, table and utf8 libraries are opened (io, os, debug and package with its require are never constructed, identically in Node and the browser), the base library's load, loadfile and dofile are removed, every chunk is compiled in text mode so binary bytecode is rejected, math.random is the host's seeded stream, and every call is bounded by instructionLimit and by memoryLimit (bytes of string and buffer data the call allocates, parsing included). The byte budget is the VM's own per-call allocation limit (limits.totalAllocation), so a refused allocation surfaces to scripts as Lua's standard not enough memory even under a script-level pcall, but the host rejects the whole call regardless. Globals persist between calls on one host, so scripts that must not influence each other need a host each.

      Parameters

      Returns ScriptHost

      import { createPyroeisScriptHost } from '@datamoc/mwg/mwl/pyroeis';

      const host = createPyroeisScriptHost();
      console.log(host.evaluate('1 + 2')); // 3
      host.dispose();