initial commit
[JIRC.git] / node_modules / jsdom / node_modules / contextify / package.json
1 {
2 "name": "contextify",
3 "version": "0.1.3",
4 "description": "Turn an object into a persistent execution context.",
5 "author": {
6 "name": "Brian McDaniel",
7 "email": "brianmcd05@gmail.com"
8 },
9 "contributors": [
10 {
11 "name": "Assaf Arkin",
12 "email": "assaf@labnotes.org",
13 "url": "http://labnotes.org/"
14 }
15 ],
16 "keywords": [
17 "context",
18 "vm"
19 ],
20 "repository": {
21 "type": "git",
22 "url": "https://github.com/brianmcd/contextify.git"
23 },
24 "main": "./lib/contextify",
25 "scripts": {
26 "test": "nodeunit test/",
27 "install": "node-gyp rebuild"
28 },
29 "engines": {
30 "node": ">=0.4.0"
31 },
32 "licenses": [
33 {
34 "type": "MIT",
35 "url": "http://github.com/brianmcd/contextify/blob/master/LICENSE.txt"
36 }
37 ],
38 "dependencies": {
39 "bindings": "*"
40 },
41 "devDependencies": {
42 "nodeunit": ">=0.5.x"
43 },
44 "gypfile": true,
45 "readme": "# Contextify\n\nTurn an object into a V8 execution context. A contextified object acts as the global 'this' when executing scripts in its context. Contextify adds 3 methods to the contextified object: run(code, filename), getGlobal(), and dispose(). The main difference between Contextify and Node's vm methods is that Contextify allows asynchronous functions to continue executing in the Contextified object's context. See vm vs. Contextify below for more discussion.\n\n## Examples\n```javascript\nvar Contextify = require('contextify');\nvar sandbox = { console : console, prop1 : 'prop1'};\nContextify(sandbox);\nsandbox.run('console.log(prop1);');\nsandbox.dispose(); // free the resources allocated for the context.\n```\n\n```javascript\nvar sandbox = Contextify(); // returns an empty contextified object.\nsandbox.run('var x = 3;');\nconsole.log(sandbox.x); // prints 3\nsandbox.dispose();\n```\n\n```javascript\nvar sandbox = Contextify({setTimeout : setTimeout});\nsandbox.run(\"setTimeout(function () { x = 3; }, 5);\");\nconsole.log(sandbox.x); // prints undefined\nsetTimeout(function () {\n console.log(sandbox.x); // prints 3\n sandbox.dispose();\n}, 10);\n```\n## Details\n\n**Contextify([sandbox])**\n\n sandbox - The object to contextify, which will be modified as described below\n If no sandbox is specified, an empty object will be allocated and used instead.\n\n Returns the contextified object. It doesn't make a copy, so if you already have a reference\n to the sandbox, you don't need to catch the return value.\n\nA Contextified object has 2 methods added to it:\n\n**run(code, [filename])**\n\n code - string containing JavaScript to execute\n filename - an optional filename for debugging.\n\n Runs the code in the Contextified object's context.\n\n**getGlobal()**\n\nReturns the actual global object for the V8 context. The global object is initialized with interceptors (discussed below) which forward accesses on it to the contextified object. This means the contextified object acts like the global object in most cases. Sometimes, though, you need to make a reference to the actual global object.\n\nFor example:\n\n```javascript\nvar window = Contextify({console : console});\nwindow.window = window;\nwindow.run(\"console.log(window === this);\");\n// prints false.\n```\n\n```javascript\nvar window = Contextify({console : console});\nwindow.window = window.getGlobal();\nwindow.run(\"console.log(window === this);\");\n// prints true\n```\n\nThe global object returned by getGlobal() can be treated like the contextified sandbox object, except that defining getters/setters will not work on it. Define getters and setters on the actual sandbox object instead.\n\n**dispose()**\n\nFrees the memory allocated for the underlying V8 context. If you don't call this when you're done, the V8 context memory will leak, as will the sandbox memory, since the context's global stores a strong reference to the sandbox object. You can still use your sandbox object after calling dispose(), but it's unsafe to use a global previously returned from getGlobal(). run, getGlobal, and dispose will be removed from the sandbox object.\n\n## Install\n\n npm install contextify\n\n## require('vm') vs. Contextify\n\nNode's vm functions (runInContext etc) work by copying the values from the sandbox object onto a context's global object, executing the passed in script, then copying the results back. This means that scripts that create asynchronous functions (using mechanisms like setTimeout) won't have see the results of executing those functions, since the copying in/out only occurs during an explicit call to runInContext and friends. \n\nContextify creates a V8 context, and uses interceptors (see: http://code.google.com/apis/v8/embed.html#interceptors) to forward global object accesses to the sandbox object. This means there is no copying in or out, so asynchronous functions have the expected effect on the sandbox object. \n\n## Tests\n\nTesting is done with nodeunit. Run the tests with\n\n nodeunit test/\n\nOutput: \n\n OK: 92 assertions (27ms)\n\n\n## Building\n\n node-waf configure build\n\n## Acknowledgments\n\nInspiration taken from Assaf's Zombie.js context solution: https://github.com/assaf/zombie\n",
46 "_id": "contextify@0.1.3",
47 "dist": {
48 "shasum": "64a61c6bb181cb3558b2e685f0e5278e99b9ec3d"
49 },
50 "_from": "contextify@0.1.x"
51 }