/sandbox-engine

A sandbox javascript.

Primary LanguageJavaScriptMIT LicenseMIT

SANDBOX

──────────────────────────────▓▓█─────── ────────────────────────────▒██▒▒█────── ───────────────────────────█▓▓▓░▒▓▓───── ─────────────────────────▒█▓▒█░▒▒▒█───── ────────────────────────▒█▒▒▒█▒▒▒▒▓▒──── ─▓▓▒░──────────────────▓█▒▒▒▓██▓▒░▒█──── ─█▓▓██▓░──────────────▓█▒▒▒▒████▒▒▒█──── ─▓█▓▒▒▓██▓░──────────▒█▒▒▒▒▒██▓█▓░░▓▒─── ─▓▒▓▒▒▒▒▒▓█▓░──░▒▒▓▓██▒▒▒▒▒▒█████▒▒▒▓─── ─▓░█▒▒▒▒▒▒▒▓▓█▓█▓▓▓▓▒▒▒▒▒▒▒▒██▓██▒░▒█─── ─▓░▓█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓████▒▒▒█─── ─▓░▓██▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒▒▒▒▓██░░░█─── ─▓░▓███▒▒▒▒▒▒▒▒▒▒▒▓█▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▒▓▓── ─▒▒▒██▓▒▓█▓▒▒▒▒▒▒▒▓▒▒▒▒▒▒▓▓▓▒▒▒▒▒▒▒▓▒█── ──▓▒█▓▒▒▒▒▓▒▒▒▒▒▒▒▒▒▒▒▓█▓▓▓▓█▓▒▒▒▒▒▒▒▓▒─ ──▓▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓──────▓█▓▒▒▒▒▒▓█─ ──▒▒▓▒▒▒▓▓▓▒▒▒▒▒▒▒▒▒▓▓───░▓▓───█▓▒▒▒▒▒█─ ───█▒▒▓▓▓▒▒▓▓▒▒▒▒▒▒▓▓───█████▓──█▓▒▒▒▒▓▒ ───▓▓█▒─────▒▓▒▒▒▒▒█───░██████──░█▒▒▒▒▓▓ ───▓█▒──▒███─▒▓▒▒▒▒█────██████───▓▒▒▒▒▒▓ ───██───█████─█▒▒▒▒█─────███▓────▓▓▒▒▒▒▓ ───█▓───█████─▒▓▒▒▒█─────────────█▓▓▓▒▒▓ ───█▓───░███──░▓▒▒▒▓█──────────░█▓▒▒▒▓▒▓ ───██─────────▒▓▒▒▒▒▓▓──────░▒▓█▓────░▓▓ ───▓█░────────█▓██▓▒▒▓█▓▓▓▓██▓▓▒▓▒░░▒▓▒▓ ───▒██░──────▓▒███▓▒▒▒▒▓▓▓▓▒▒▒▒▒▒▓▓▓▓▒▓─ ────█▓█▓▓▒▒▓█▓▒░██▒▒▓▓█▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓█▒ ────▓─░▓▓▓▓▓▒▓▓▓▓▒▓▓▓▒▓▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓ ────▒▒▒▓▒▒▒▒▒▒▓█░─░░░─▓▓▒▒▒▒▒▒▒▒▒▒▒▓██▓▒ ─────█▓▒▒▒▒▒▒▒▒▓▓─░░░─▓▓▒▒▒▒▒▒▒▒▒▓▓▓▒▒▓▒ ──────██▓▓▒▒▒▒▒▒█▒░░░░█▒▒▒▒▒▒▒▒▓█▓▓▒▒▒▒▒ ─────░─▒██▓▓▒▒▒▒▒█▓▒▒▓▒▒▒▒▒▒▓███▓▒▒▒▒▒▓▓ ──────────░▒▓▓▓▓▒▒▓▓▓▓▓▓████▓▓█▒▒▒▒▒▓▓█░

Execution of strings as code in sandbox environments.

Usage

Executes the string as code in the context of the passed object. The string can be any valid JavaScript code. Executes code in sandbox, can't interact with main thread variable

const sandbox = new Sandbox()
sandbox.exec(`
  function add (number1) {
    return number1 + 1
  }
  const result = add(a)
  console.log(result) // Return: 101
`, (message) {
  // Message from sandbox
})