Created
February 11, 2013 16:54
-
-
Save geNAZt/4755698 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vm = require('vm'), | |
ctx = vm.createContext({setTimeout: setTimeout, console: console}), | |
script = vm.createScript("now = 1; setTimeout(function() { now = 2; console.log('Inside the VM: ' + now); }, 1000);"); | |
script.runInContext(ctx); | |
setInterval(function () { | |
console.log("Outside the VM: " + ctx.now); | |
}, 500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Outside the VM: 1
Outside the VM: 1
Inside the VM: 2
Outside the VM: 1
Outside the VM: 1
Outside the VM: 1
Outside the VM: 1