vm-browserify

WebJar for vm-browserify

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

vm-browserify
Last Version

Last Version

1.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

vm-browserify
WebJar for vm-browserify
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/browserify/vm-browserify

Download vm-browserify

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/vm-browserify/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>vm-browserify</artifactId>
    <version>1.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/vm-browserify/
implementation 'org.webjars.npm:vm-browserify:1.1.2'
// https://jarcasting.com/artifacts/org.webjars.npm/vm-browserify/
implementation ("org.webjars.npm:vm-browserify:1.1.2")
'org.webjars.npm:vm-browserify:jar:1.1.2'
<dependency org="org.webjars.npm" name="vm-browserify" rev="1.1.2">
  <artifact name="vm-browserify" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='vm-browserify', version='1.1.2')
)
libraryDependencies += "org.webjars.npm" % "vm-browserify" % "1.1.2"
[org.webjars.npm/vm-browserify "1.1.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

vm-browserify

emulate node's vm module for the browser

Build Status

example

Just write some client-side javascript:

var vm = require('vm');

window.addEventListener('load', function () {
    var res = vm.runInNewContext('a + 5', { a : 100 });
    document.querySelector('#res').textContent = res;
});

compile it with browserify:

browserify entry.js -o bundle.js

then whip up some html:

<html>
  <head>
    <script src="/bundle.js"></script>
  </head>
  <body>
    result = <span id="res"></span>
  </body>
</html>

and when you load the page you should see:

result = 105

methods

vm.runInNewContext(code, context={})

Evaluate some code in a new iframe with a context.

Contexts are like wrapping your code in a with() except slightly less terrible because the code is sandboxed into a new iframe.

install

This module is depended upon by browserify, so you should just be able to require('vm') and it will just work. However if you want to use this module directly you can install it with npm:

npm install vm-browserify

license

MIT

org.webjars.npm

Versions

Version
1.1.2
1.1.0
1.0.1
0.0.4