sandbox-brower
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

sandboxjs

A nifty javascript sandbox for browser. When its dispose is called, all defined global variables will be destroyed,Includes timers and global events.

Installing it

npm install sandbox-brower

Using it

const sandbox = new Sandbox();
const scriptText = 'window.customName = "jay"; console.log(window.customName);' ;
sandbox.execScript(scriptText); // 'jay'
sandbox.dispose(); // destroy the sandbox
console.log(window.customName); // undefined

other

If you have some variables defined on window outside the sandbox, you can still use them inside the sandbox

window.globalProp = 'hello world'
const sandbox = new Sandbox();
const scriptText = 'console.log(window.globalProp);' ; 
sandbox.execScript(scriptText);// 'hello world'

Package Sidebar

Install

npm i sandbox-brower

Weekly Downloads

4

Version

1.0.7

License

ISC

Unpacked Size

29.9 kB

Total Files

7

Last publish

Collaborators

  • zengyong