emulate node\textquotesingle{}s vm module for the browser

\href{https://travis-ci.org/browserify/vm-browserify}{\texttt{ }}\hypertarget{md_sfcode_node_modules_vm_browserify_readme_autotoc_md31812}{}\doxysection{example}\label{md_sfcode_node_modules_vm_browserify_readme_autotoc_md31812}
Just write some client-\/side javascript\+:


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

\end{DoxyCode}


compile it with \href{http://github.com/substack/node-browserify}{\texttt{ browserify}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{browserify entry.js -\/o bundle.js }

\end{DoxyCode}


then whip up some html\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{<html>}
\DoxyCodeLine{  <head>}
\DoxyCodeLine{    <script src="{}/bundle.js"{}></script>}
\DoxyCodeLine{  </head>}
\DoxyCodeLine{  <body>}
\DoxyCodeLine{    result = <span id="{}res"{}></span>}
\DoxyCodeLine{  </body>}
\DoxyCodeLine{</html> }

\end{DoxyCode}


and when you load the page you should see\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{result = 105 }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_vm_browserify_readme_autotoc_md31813}{}\doxysection{methods}\label{md_sfcode_node_modules_vm_browserify_readme_autotoc_md31813}
\hypertarget{md_sfcode_node_modules_vm_browserify_readme_autotoc_md31814}{}\doxysubsection{vm.\+run\+In\+New\+Context(code, context=\{\})}\label{md_sfcode_node_modules_vm_browserify_readme_autotoc_md31814}
Evaluate some {\ttfamily code} in a new iframe with a {\ttfamily context}.

Contexts are like wrapping your code in a {\ttfamily with()} except slightly less terrible because the code is sandboxed into a new iframe.\hypertarget{md_sfcode_node_modules_vm_browserify_readme_autotoc_md31815}{}\doxysection{install}\label{md_sfcode_node_modules_vm_browserify_readme_autotoc_md31815}
This module is depended upon by browserify, so you should just be able to `require(\textquotesingle{}vm')\`{} and it will just work. However if you want to use this module directly you can install it with \href{http://npmjs.org}{\texttt{ npm}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{npm install vm-\/browserify }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_vm_browserify_readme_autotoc_md31816}{}\doxysection{license}\label{md_sfcode_node_modules_vm_browserify_readme_autotoc_md31816}
MIT 