Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@garfish/browser-vm

Package Overview
Dependencies
Maintainers
8
Versions
369
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@garfish/browser-vm

vm-sandbox module.

  • 0.0.9
  • Source
  • npm
  • Socket score

Version published
Maintainers
8
Created
Source

@garfish/vm-sandbox

Usage

import vmSandbox from '@garfish/vm-sandbox';

let nameMap = { a: 'chen' };

const sandbox = new vmSandbox({
  namespace: 'app',
  el: () => document.body,
  modules: [
    () => ({
      override: { nameMap },
      recover() {
        nameMap = { a: 'chen' };
      },
    }),
  ],
});

sandbox.execScript(`
  window.x = 1;
  console.log(window.nameMap); // { a: 'chen' }
  window.nameMap.a = 'tao';
`);

console.log(sandbox.global.x); // 1
console.log(sandbox.global.nameMap); // { a: 'tao' }

// Clear effect
sandbox.clearEffects();
console.log(nameMap); // { a: 'chen' }

// If clear all effects
sandbox.reset();

Keywords

FAQs

Package last updated on 22 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc