{"_id":"sandbox-runner","_rev":"6-bdcc48bdd627a37cf10745fe7f8878aa","name":"sandbox-runner","description":"Run javascript in a sandbox context","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"sandbox-runner","version":"0.1.0","description":"Run javascript in a sandbox context","main":"index.js","scripts":{"test":"gulp mocha"},"repository":{"type":"git","url":"https://github.com/timnew/sandbox-runner"},"keywords":["sandbox","eval","isolation"],"author":{"name":"timnew","email":"timnew.wti@gmail.com","url":"https://timnew.github.io/"},"license":"MIT","bugs":{"url":"https://github.com/timnew/sandbox-runner/issues"},"homepage":"https://github.com/timnew/sandbox-runner","devDependencies":{"chai":"^1.9.1","coffee-script":"~1.7.1","del":"^0.1.1","gulp":"^3.8.6","gulp-bump":"^0.1.10","gulp-coffee":"^2.1.0","gulp-mocha":"^0.5.0","mocha":"^1.20.1","yargs":"^1.2.6"},"gitHead":"442f10d7626f71bd89ff1e3a980f4d0261feca93","_id":"sandbox-runner@0.1.0","_shasum":"691e7517a080925b02911351061d55a72220dcdc","_from":".","_npmVersion":"1.4.20","_npmUser":{"name":"timnew","email":"timnew.wti@gmail.com"},"maintainers":[{"name":"timnew","email":"timnew.wti@gmail.com"}],"dist":{"shasum":"691e7517a080925b02911351061d55a72220dcdc","tarball":"https://registry.npmjs.org/sandbox-runner/-/sandbox-runner-0.1.0.tgz","integrity":"sha512-Fj5o2os9Pamn3vXKHpjrVaMswSyp52NS6X00+odQ8u1Mym0JUCG71dUwJCcQemjrMzNmOS4Dh0oZ489GO8QFWA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF41AQLTqNIo5G03+deL+5k25Rdf6GFYNy6WucS8sedBAiAvD/zvJNri0wLXwZnFcduJ7HTu9scrdTP3bf12P1+xPw=="}]}},"0.1.1":{"name":"sandbox-runner","version":"0.1.1","description":"Run javascript in a sandbox context","main":"index.js","scripts":{"test":"gulp mocha"},"repository":{"type":"git","url":"https://github.com/timnew/sandbox-runner"},"keywords":["sandbox","eval","isolation"],"author":{"name":"timnew","email":"timnew.wti@gmail.com","url":"https://timnew.github.io/"},"license":"MIT","bugs":{"url":"https://github.com/timnew/sandbox-runner/issues"},"homepage":"https://github.com/timnew/sandbox-runner","devDependencies":{"chai":"^1.9.1","coffee-script":"~1.7.1","del":"^0.1.1","gulp":"^3.8.6","gulp-bump":"^0.1.10","gulp-coffee":"^2.1.0","gulp-mocha":"^0.5.0","mocha":"^1.20.1","yargs":"^1.2.6"},"gitHead":"ebd4012df44a175817dd57895493f30ae815c6cd","_id":"sandbox-runner@0.1.1","_shasum":"f364c62c9e281e5085eb031d9dd4ea7f7f61d33d","_from":".","_npmVersion":"1.4.20","_npmUser":{"name":"timnew","email":"timnew.wti@gmail.com"},"maintainers":[{"name":"timnew","email":"timnew.wti@gmail.com"}],"dist":{"shasum":"f364c62c9e281e5085eb031d9dd4ea7f7f61d33d","tarball":"https://registry.npmjs.org/sandbox-runner/-/sandbox-runner-0.1.1.tgz","integrity":"sha512-FjxYhc1CVbagWIR8lIfisF5Sqe0M8K1g1fOVE0CL9/VcmFG5f9KIt6rSBA8Iecq1rdUT21XXkqjGh3zdteTTFQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC1HmwpUIUhy6hMRoX+HQlnIdv4HikSqgf66zOybzNlOAiEArWkXUIphgryYpwm+bPCbU+Q4mZSwtM64Q9Mk3DfhuYE="}]}}},"readme":"sandbox-runner [![NPM version][npm-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Dependency Status][depstat-image]][depstat-url]\n================\n\n> Eval a piece of javascript text in a sandbox environment\n> Could be useful to test code generation or test javascript without proper module encapsulation.\n\n## Install\n\nInstall using [npm][npm-url].\n\n    $ npm install sandbox-runner\n\n## Usage\n\n```javascript\n\nvar fs = require('fs');\nvar sandbox = require('sandbox-runner');\n\nvar codeSnippet = fs.readFileSync('./templates.js', {encoding:'utf8'});\n\n/* Content of templates.js\nthis.Templates = this.Templates != null ? this.Templates : {};\nthis.Templates[\"hello\"] = function (name) {\n            return 'hello ' + name + '!';\n          };\nthis.Templates[\"foo\"] = function () {\n            return 'foo';\n          };\n*/\n\nvar context = sandbox.run(codeSnippet);\n\ncontext.Templates.hello('world').should.equal('hello world !');\n\n```\n\n## API\n\n### `sanbox.run(script, context = {})`\n\n> run the script snippet, a `context` is provided as `this` pointer.\n\n* **script** The script text to be executed\n* **context** The context that used in execution. An empty object will be provide if omitted.\n\n** HINT ** Exception is thrown when error occurs in script. Remember to catch the exception in async code.\n\n### `sandbox.moduleRun(script, filename = '')`\n\n> run the script snippet as a node.js module\n\n* **script** The script text to be executed\n* **filenae** The fake file name that of the module in file system.\n\n## License\nMIT\n\n[![NPM downloads][npm-downloads]][npm-url]\n\n[npm-url]: https://npmjs.org/package/sandbox-runner\n[npm-image]: http://img.shields.io/npm/v/sandbox-runner.svg?style=flat\n[npm-downloads]: http://img.shields.io/npm/dm/sandbox-runner.svg?style=flat\n\n[ci-url]: https://drone.io/github.com/timnew/sandbox-runner/latest\n[ci-image]: https://drone.io/github.com/timnew/sandbox-runner/status.png\n\n[depstat-url]: https://gemnasium.com/timnew/sandbox-runner\n[depstat-image]: http://img.shields.io/gemnasium/timnew/sandbox-runner.svg?style=flat\n","maintainers":[{"name":"timnew","email":"timnew.wti@gmail.com"}],"time":{"modified":"2022-06-26T15:52:40.607Z","created":"2014-07-12T16:36:05.188Z","0.1.0":"2014-07-12T16:36:05.188Z","0.1.1":"2014-07-12T16:56:44.434Z"},"homepage":"https://github.com/timnew/sandbox-runner","keywords":["sandbox","eval","isolation"],"repository":{"type":"git","url":"https://github.com/timnew/sandbox-runner"},"author":{"name":"timnew","email":"timnew.wti@gmail.com","url":"https://timnew.github.io/"},"bugs":{"url":"https://github.com/timnew/sandbox-runner/issues"},"license":"MIT","readmeFilename":"README.md"}