{"id":19806631,"url":"https://github.com/timnew/sandbox-runner","last_synced_at":"2025-07-10T12:07:45.928Z","repository":{"id":18567334,"uuid":"21769748","full_name":"timnew/sandbox-runner","owner":"timnew","description":"Run javascript in a sandbox context","archived":false,"fork":false,"pushed_at":"2014-07-12T16:57:19.000Z","size":144,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-02T16:04:40.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/timnew/sandbox-runner","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timnew.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-12T15:11:29.000Z","updated_at":"2015-03-16T09:24:28.000Z","dependencies_parsed_at":"2022-08-05T00:15:41.435Z","dependency_job_id":null,"html_url":"https://github.com/timnew/sandbox-runner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timnew%2Fsandbox-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timnew%2Fsandbox-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timnew%2Fsandbox-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timnew%2Fsandbox-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timnew","download_url":"https://codeload.github.com/timnew/sandbox-runner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timnew%2Fsandbox-runner/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258421328,"owners_count":22698454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T09:08:03.316Z","updated_at":"2025-07-10T12:07:45.870Z","avatar_url":"https://github.com/timnew.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"sandbox-runner [![NPM version][npm-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Dependency Status][depstat-image]][depstat-url]\n================\n\n\u003e Eval a piece of javascript text in a sandbox environment\n\u003e 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\u003e 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\u003e 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimnew%2Fsandbox-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimnew%2Fsandbox-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimnew%2Fsandbox-runner/lists"}