Sha256: 9afc9d565e726fa6c12805d6722e1b6a51a09a67f52bb24f8c3a83bb0642d3e9

Contents?: true

Size: 1.3 KB

Versions: 16

Compression:

Stored size: 1.3 KB

Contents

# vm-browserify

emulate node's vm module for the browser

[![Build Status](https://travis-ci.org/browserify/vm-browserify.svg?branch=master)](https://travis-ci.org/browserify/vm-browserify)

# example

Just write some client-side javascript:

``` js
var vm = require('vm');

$(function () {
    var res = vm.runInNewContext('a + 5', { a : 100 });
    $('#res').text(res);
});
```

compile it with [browserify](http://github.com/substack/node-browserify):

```
browserify entry.js -o bundle.js
```

then whip up some html:

``` html
<html>
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <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](http://npmjs.org):

```
npm install vm-browserify
```

# license

MIT

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
disco_app-0.18.0 test/dummy/node_modules/vm-browserify/readme.markdown
disco_app-0.18.2 test/dummy/node_modules/vm-browserify/readme.markdown
disco_app-0.16.1 test/dummy/node_modules/vm-browserify/readme.markdown
disco_app-0.15.2 test/dummy/node_modules/vm-browserify/readme.markdown
disco_app-0.18.4 test/dummy/node_modules/vm-browserify/readme.markdown
disco_app-0.18.1 test/dummy/node_modules/vm-browserify/readme.markdown
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/vm-browserify/readme.markdown
disco_app-0.14.0 test/dummy/node_modules/vm-browserify/readme.markdown
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/vm-browserify/readme.markdown
jester-data-8.0.0 node_modules/vm-browserify/readme.markdown
ezii-os-5.2.1 node_modules/vm-browserify/readme.markdown
ezii-os-2.0.1 node_modules/vm-browserify/readme.markdown
ezii-os-1.1.0 node_modules/vm-browserify/readme.markdown
ezii-os-1.0.0 node_modules/vm-browserify/readme.markdown
ezii-os-0.0.0.1.0 node_modules/vm-browserify/readme.markdown
ezii-os-0.0.0.0.1 node_modules/vm-browserify/readme.markdown