0.0.11 • Published 6 years ago

z-sandbox v0.0.11

Weekly downloads
16
License
MIT
Repository
github
Last release
6 years ago

A simple Sandbox implementation for JavaScript

Preview

preview

Demo

Edit quirky-microservice-8oqog

How to use

Install from the npm

npm install z-sandbox
# or
yarn add z-sandbox

Use in your code

import { createSandbox } from 'z-sandbox';

const sandboxOptions = {
    // default: false
    useStrict: false,
    // default: true
    inheritGlobal: true,
    // default: []
    blacklist: ['blacklistContent']
};

const context = {
    blacklistContent: "this content is in the blacklist, you can't get it in the sandbox",
    hello: 'hello z-sandbox'
};

const sandbox = createSandbox(context, sandboxOptions);

sandbox`
    // should be undefined
    console.log(blacklistContent);
    // should be undefined
    console.log(window.blacklistContent);
    // should be undefined
    console.log(this.blacklistContent);
    // should be undefined
    console.log(self.blacklistContent);

    // should be 'hello z-sandbox'
    console.log(hello);

    window.testInject = true;
    // should be true
    console.log(window.testInject);
`;
// should be undefined, false
console.log(window.testInject, 'testInject' in window);
0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago