{"_id":"modulebox","_rev":"30-fe5966c2dc7aee73ceaac24e26460049","name":"modulebox","description":"node.js like module environment in the browser","dist-tags":{"latest":"1.4.0"},"versions":{"0.2.0":{"name":"modulebox","description":"node.js like module environment in the browser","version":"0.2.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./modulebox.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","exports"],"dependencies":{"async":"0.1.x","endpoint":"0.2.x","localizer":"0.2.x","detective":"0.2.x","startpoint":"0.2.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.3.x","blow":"0.7.x"},"license":"MIT","engines":{"node":"0.10 || 0.9","npm":"1"},"_id":"modulebox@0.2.0","dist":{"shasum":"7dc9a1df7ea0b281448f551c740e05db40756a96","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-0.2.0.tgz","integrity":"sha512-49Obaw9uB2dUnvKwoZV/cd/xDg2KByIOfhBPIFQIn+FQtTh9y0YwqeZajxGOWsdFr26IcV1O4VVis8WZ6HxtOg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHQbWyPCMBOApD9phW/PFNIWdgFtUWTxw23g8T87FExtAiA8Sp6/+1YlgFgaNK9yMeSqa2R42+QhnjVhviCqVtjr/Q=="}]},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"0.2.1":{"name":"modulebox","description":"node.js like module environment in the browser","version":"0.2.1","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./modulebox.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","exports"],"dependencies":{"async":"0.1.x","endpoint":"0.2.x","localizer":"0.2.x","detective":"0.2.x","startpoint":"0.2.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.3.x","blow":"0.7.x","filed":"0.0.x"},"license":"MIT","engines":{"node":"0.10 || 0.9","npm":"1"},"_id":"modulebox@0.2.1","dist":{"shasum":"ccfe384ed7e8addb7cf42a402188310349880aed","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-0.2.1.tgz","integrity":"sha512-BN1UdylyMQIikDrm0kvVKACDuUZFMAZE9XEAav3C0CkQqvn0Ti6axB+17CbK6cTovlSBj2GFiUYaHR+sDAcyZQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICsil0rV4vfnQYRFTKWqF5odK3n6RcAVVIIgHKOqn64jAiAIs9lJFntO1hTL/HKk1TEEHLNBUm52+LxJD5klHkASuQ=="}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"0.2.2":{"name":"modulebox","description":"node.js like module environment in the browser","version":"0.2.2","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./lib/dispatch.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","exports"],"dependencies":{"async":"0.1.x","endpoint":"0.2.x","localizer":"0.2.x","detective":"0.2.x","startpoint":"0.2.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.3.x","blow":"0.7.x","filed":"0.0.x"},"license":"MIT","engines":{"node":"0.10 || 0.9","npm":"1"},"_id":"modulebox@0.2.2","dist":{"shasum":"c3c82e8b16caf92252aca1bbd43d022c277c6b0f","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-0.2.2.tgz","integrity":"sha512-ke/ePKbu7bCklns03JGnRkt0w9dHPPasOvcpG6WBOld1XDphoK4TwxeWQfZVEnwwE5iaHH8M9Zk/SSbk+teIyA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICj+7X/RPuBc6esSZMevLOs9pVnouZ4YLrqbxBwssGiYAiAOmchYGkNtoU5+T3je2zHosH2TKY/fCqf3CkQuEThkgA=="}]},"_from":".","_npmVersion":"1.2.15","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"1.0.0":{"name":"modulebox","description":"node.js like module environment in the browser","version":"1.0.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./lib/dispatch.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","commonjs","exports"],"dependencies":{"async":"0.2.x","filed":"0.1.x","endpoint":"0.4.x","commondir":"0.0.x","localizer":"0.2.x","detective":"2.1.x","startpoint":"0.3.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.4.x","blow":"0.7.x"},"license":"MIT","engines":{"node":"0.10 || 0.11","npm":"1"},"bugs":{"url":"https://github.com/AndreasMadsen/modulebox/issues"},"_id":"modulebox@1.0.0","dist":{"shasum":"cff931ea4d015c7a09326a4dbd2393d3417af960","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-1.0.0.tgz","integrity":"sha512-aY4jGeQARLOSC03b4dmd1Ko8XivEtTPg8/r7HISunhI560cTfweGSNFnuUsUTYve+bRBfeShl/LcQLzO8A7WRg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCr9LyvjwVLL+FSUkLJWJiGJRtx4+5cRcdA7EhMz+h6EAIhAOA+hp2SUhrBiXxFV/6fuqwbVAjnmozPd1zKnPkG8d70"}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"1.1.0":{"name":"modulebox","description":"node.js like module environment in the browser","version":"1.1.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./lib/dispatch.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","commonjs","exports"],"dependencies":{"async":"0.2.x","filed":"0.1.x","endpoint":"0.4.x","commondir":"0.0.x","localizer":"0.2.x","detective":"2.1.x","startpoint":"0.3.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.4.x","blow":"0.7.x"},"license":"MIT","engines":{"node":"0.10 || 0.11","npm":"1"},"bugs":{"url":"https://github.com/AndreasMadsen/modulebox/issues"},"_id":"modulebox@1.1.0","dist":{"shasum":"a98d70b8738c1fa487a07d88b6c512950ea64e57","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-1.1.0.tgz","integrity":"sha512-hiz44qVi+Fs9jPjQkfUUmboH9LmFyqkPWcxmSreiGcdokrHVer3IBuR8DBj8WlLEDPbDmPsFidI5/dmbxGyjNg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIElKDA0axX+ttnmFCC3qn7MPoSpSoWQ32BEIh02qRWy6AiArtpqeOQImihqDpJVXy5HBumEGPxk/z4dJWk/T5ou/uQ=="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"1.2.0":{"name":"modulebox","description":"node.js like module environment in the browser","version":"1.2.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./lib/dispatch.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","commonjs","exports"],"dependencies":{"async":"0.2.x","filed":"0.1.x","endpoint":"0.4.x","commondir":"0.0.x","localizer":"0.2.x","detective":"2.1.x","startpoint":"0.3.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.4.x","blow":"0.7.x"},"license":"MIT","engines":{"node":"0.10 || 0.11","npm":"1"},"bugs":{"url":"https://github.com/AndreasMadsen/modulebox/issues"},"_id":"modulebox@1.2.0","dist":{"shasum":"32a38bfedd8e0f0a899152e0d2c857b8b81820b2","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-1.2.0.tgz","integrity":"sha512-9oTqjanlipVB63zipZWEmxgjeVFJoeBYuqm4cvChcVP3HZX0X8FNKVgTl4XKwJjNfyFTv+A4qQO38bBp/dDeRw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDyDArdZZjqBDs1C/GrE+hPvBKh5jZFi2KphpKF7dgR+wIhAMV03qtrfRvvOfragsE6MqvV0vBY8bc/LOd9qp7tBfQk"}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"1.2.1":{"name":"modulebox","description":"node.js like module environment in the browser","version":"1.2.1","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./lib/dispatch.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","commonjs","exports"],"dependencies":{"async":"0.2.x","filed":"0.1.x","endpoint":"0.4.x","commondir":"0.0.x","localizer":"0.2.x","detective":"2.1.x","startpoint":"0.3.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.4.x","blow":"0.7.x"},"license":"MIT","engines":{"node":"0.10 || 0.11","npm":"1"},"bugs":{"url":"https://github.com/AndreasMadsen/modulebox/issues"},"_id":"modulebox@1.2.1","dist":{"shasum":"bbbe8c6b91ee7aad7913b5792a4c6e66028c7410","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-1.2.1.tgz","integrity":"sha512-CRMLRbrSDR+pCgn39fpGKn9gZs0BxajuwaW66VEq03Z6gOziqpGhQAqCz6bjumuEVtIEdqIdh6F3zfCTcQzGwA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF0flEDVxHpA5onAQOuYEm+ML3MxpdusyaMVA+Tx2PRPAiB5KSeQ40DuEv9RIc5a0bOnaXQoddP/uJg2yqu65PIKfg=="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"1.2.2":{"name":"modulebox","description":"node.js like module environment in the browser","version":"1.2.2","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./lib/dispatch.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","commonjs","exports"],"dependencies":{"async":"0.2.x","filed":"0.1.x","endpoint":"0.4.x","commondir":"0.0.x","localizer":"0.2.x","detective":"2.1.x","startpoint":"0.3.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.4.x","blow":"0.7.x"},"license":"MIT","engines":{"node":"0.10 || 0.11","npm":"1"},"bugs":{"url":"https://github.com/AndreasMadsen/modulebox/issues"},"_id":"modulebox@1.2.2","dist":{"shasum":"8553989967705bc3e05dc7047af6be0fbf037f5c","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-1.2.2.tgz","integrity":"sha512-X4DZEMzC2287B1cv8NJXlar9ynkgn4v6qEbLQALmsSHjnUOH+YM1l0TLe/91uHod+wviWSyAr/CiLE1ylWpiKw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC1HeOnuBG86GV8pB5k/sy9qrqTNVMWo91FSBPuX9TJIAiAl7ARoQCi4thPEXToCNAyTbkIadqD2v+Wu/KNWEqoGHg=="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"1.2.3":{"name":"modulebox","description":"node.js like module environment in the browser","version":"1.2.3","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./lib/dispatch.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","commonjs","exports"],"dependencies":{"async":"0.2.x","filed":"0.1.x","endpoint":"0.4.x","commondir":"0.0.x","localizer":"0.2.x","detective":"2.1.x","startpoint":"0.3.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.4.x","blow":"0.7.x"},"license":"MIT","engines":{"node":"0.10 || 0.11","npm":"1"},"bugs":{"url":"https://github.com/AndreasMadsen/modulebox/issues"},"_id":"modulebox@1.2.3","dist":{"shasum":"2c23099b464f80f414992977fe728d5e529d458c","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-1.2.3.tgz","integrity":"sha512-TaXk088c+Q3M8+11/l9YpJ4H81NkXIsDld5cM1nhvkZpQHR/8LtxhATgQpBLn9XNiqg69lYPheJrSJuqky5IrQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCnHeujuBqztqy5s2hfE1klg/0GZvli7mnidxth/m1LDwIgZj4ucKVcknIhcA9GSEkohiUKFYTuCAfx8NchcCHYQIU="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"1.2.4":{"name":"modulebox","description":"node.js like module environment in the browser","version":"1.2.4","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./lib/dispatch.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","commonjs","exports"],"dependencies":{"async":"0.2.x","filed":"0.1.x","endpoint":"0.4.x","commondir":"0.0.x","localizer":"0.2.x","detective":"2.1.x","startpoint":"0.3.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.4.x","blow":"0.7.x"},"license":"MIT","engines":{"node":"0.10 || 0.11","npm":"1"},"bugs":{"url":"https://github.com/AndreasMadsen/modulebox/issues"},"_id":"modulebox@1.2.4","dist":{"shasum":"0e2af8b866c066ca214a14de0f26860cfd487ade","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-1.2.4.tgz","integrity":"sha512-9gxHfLpCNqLNm+C7LW/ffI3Vg92TGiadWNWVBti3bQLsAJFiiLKavaPf6iNY162/PqcqD3ltgfXb7wiMrZwXsg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDa6RYK8d2uoV2HxsrO1W0xVaBHtI+b0PDFWz0IIKDKGgIgSj97Ox/btBe3fA0obo6JyPDyEyhtrx6hZ7fltRqhM6E="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"1.3.0":{"name":"modulebox","description":"node.js like module environment in the browser","version":"1.3.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./lib/dispatch.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","commonjs","exports"],"dependencies":{"async":"0.2.x","filed":"0.1.x","endpoint":"0.4.x","commondir":"0.0.x","localizer":"0.2.x","detective":"2.1.x","startpoint":"0.3.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.4.x","blow":"0.7.x"},"license":"MIT","engines":{"node":"0.10 || 0.11","npm":"1"},"bugs":{"url":"https://github.com/AndreasMadsen/modulebox/issues"},"_id":"modulebox@1.3.0","dist":{"shasum":"20516b3b95981900874b9b69c2d1be8f11af062f","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-1.3.0.tgz","integrity":"sha512-a+9/ncfa8gpB32wITFSnEGZHLheOQmg2B97H2/BTIEN75c4AuiNvyG9Avy0yJGIItx7P3EKLLUAW9YedlXRYWg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHWtU2qVV77WLTHvnNFe0YrV3PJr1tq7CednffUlI2fHAiEAqfK4Ztv+xzogk5ckNDNchP53GBHmR7iHyuCxT/paYnQ="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"directories":{}},"1.4.0":{"name":"modulebox","description":"node.js like module environment in the browser","version":"1.4.0","author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"main":"./lib/dispatch.js","scripts":{"test":"tap test/server/*","test-browser":"node test/browser-runner/start.js"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"keywords":["module","require","commonjs","exports"],"dependencies":{"async":"0.2.x","filed":"0.1.x","endpoint":"0.4.x","commondir":"0.0.x","localizer":"0.2.x","detective":"2.1.x","startpoint":"0.3.x","notmodified":"0.2.x"},"devDependencies":{"tap":"0.4.x","blow":"0.7.x"},"license":"MIT","bugs":{"url":"https://github.com/AndreasMadsen/modulebox/issues"},"homepage":"https://github.com/AndreasMadsen/modulebox","_id":"modulebox@1.4.0","dist":{"shasum":"86012ff1cb756a3e46da878e5dac02bc13d39a7b","tarball":"https://registry.npmjs.org/modulebox/-/modulebox-1.4.0.tgz","integrity":"sha512-BW0o8uJXyg4aU2roJL2SmlA8J0siJtgxGXa1KZS9lTy1caxAvrlyACRDpQy5kPzOlQCgc+eCGiuTcRMLomlfhg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDl5jUOIzfVHFQ5mnmp3SeZrc9gqqJ5cHiF3Z7Ko7ElTAIhAIC/Y6L4IbGVnNMZ0qBhYKafTD+5RiRM/LZ3n76tkT7H"}]},"_from":".","_npmVersion":"1.3.22","_npmUser":{"name":"andreasmadsen","email":"amwebdk@gmail.com"},"maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}]}},"readme":"#modulebox\n\n> `modulebox` creates a node.js like require system in the browser. It provides\na localized secure module environment, there allow pseudo-synchronous require\ncalls there don't block by resolving the dependencies tree on the fly.\n\n> It is diffrent from most other `node.js in the browser` systems, by being backed\nby a server which enables you to load modules as they become needed, instead of\nloading the entire website or application at once.\n\n## Installation\n\n```sheel\nnpm install modulebox\n```\n\n## Features\n\n* Pseudo-synchronous require calls\n* Customizable `require.resolve` algoritme\n* Source mapping, produces accurate stack traces\n* Blocking `require` fallback, if module source isn't prefetched\n* Automaticly http headers and handles cache control\n* Limits `require.resolve` to a designated directory\n* No pre-analyzing required\n\n## Browser support\n\n* Chrome\n* Firefox\n* Opera\n* Safari\n* Internet Explore 9\n\n## Example\n\n**server.js**\n\n```javascript\nvar http = require('http');\nvar modulebox = require('modulebox');\n\n// You should have a directory where all your client modules are, in this case\n//  it is `__dirname + '/secure'`. This directory will serve as a fake root\n//  from which filepaths are calculate.\nvar box = modulebox({\n  root: __dirname + '/secure'\n});\n\n// Next you create a simple server\nvar server = http.createServer(function (req, res) {\n  // Usually you would have a router where you check for /modulebox/\n  if (req.url.slice(0, 11) === '/modulebox/') {\n    box.dispatch(req, res);\n  } else {\n    // Do your usual stuff, such as serving `index.html?\n  }\n});\n```\n\n**index.html**\n\n```html\n<html>\n  <!-- this script sets window.modulebox -->\n  <script src=\"/modulebox/core.js\"></script>\n  <script>(function () {\n    // you should then create a box object\n    var box = window.modulebox();\n\n    // `box` provides you with `require`, `require.resolve` and `requre.ensure`\n    //  the last is important since it loads modules asynchronously\n    box.require.ensure(['/module_1.js', '/module_2.js'], function (err) {\n      if (err) throw err;\n\n      // Now that the `module_1.js` and `module_1.js` and all their dependencies\n      //  are loaded you can use `box.require` without doing a synchronously XHR.\n      box.require('/module_1.js');\n      box.require('/module_2.js');\n    });\n  })();</script>\n</html>\n```\n\n**__dirname + '/secure/module_1.js'**\n\n```javascript\n// within your modules `require`, `module`, `exports`, __dirname, __filename\n//  are defined and `require` calles will already be loaded.\nvar realmodule = require('realmodule');\n\n// You can also loadd modules asynchronously with `require.ensure`\nrequire.ensure(['anothermodule'], function (err) {\n  if (err) throw err;\n});\n```\n\n## API documentation\n\nThe `modulebox` consists of three parts:\n\n* A modulebox server (node.js)\n* A client, creating a module environment (browser)\n* The module environment (browser)\n\n### modulebox server\n\nThe module exports a `modulebox` constructor.\n\n```javascript\nvar modulebox = require('modulebox');\n```\n\nThe constructor takes an settings object, with the following properties:\n\n* `root`: designated secure directory (default: '/')\n* `modules`: directory name of modules (default: 'node_modules')\n* `allowed`: specify basename search pattern\n* `special`: an object mapping module names to files, only required if you want core modules\n\nSee [localizer](https://github.com/AndreasMadsen/localizer#documentation) for more details\non `root`, `modules` and `allowed`.\n\n```javascript\nvar builtins = require('browser-builtins');\nvar box = modulebox({\n  root: path.resolve(__dirname, 'secure'),\n  special: builtins\n});\n```\n\n#### box.dispatch(req, res)\n\n`box.dispatch` is a method there will read the query parameters of `req.url`\ndefined by the client and send the requested module or send the `core.js` file.\nIt will also take care of cache control headers such as `etag` and `last-modified`.\n\n```javascript\nhttp.createServer(function (req, res) {\n  if (req.url.slice(0, 11) === '/modulebox/') {\n    box.dispatch(req, res);\n  }\n});\n```\n\n### modulebox client (browser)\n\nAfter the `core.js` script has been loaded by the browser, the `window.modulebox`\nwill be available. This method is a `modulebox` constructor there after initializing\nexposes a way to fetch and require modules.\n\nThe `window.modulebox` constructor takes the following properties:\n\n* `baseUrl`: the url to send module requests (default: 'http(s)://{host}/modulebox/')\n* `sourcePath`: the pathname modules will be in the source map (default '/modulebox/files/');\n\n```javascript\nvar box = window.modulebox({\n  baseUrl: window.location.protocol + '//' + window.location.host + '/base/',\n  sourcePath: '/modules/'\n});\n```\n\n#### box.require(module)\n\nThis is just like the `require` function in node.js, it returns the\n`module.exports` value.\n\nHowever unlike the `require` function it is not called from a specific module\nbut from the root as defined by the `root` property on the server-side.\n\nAlso note that if the module wasn't prefetched with `box.require.ensure` it\nwill be loaded synchronously, which will block the javascript execution in the\nbrowser. If this is the case you will be warned by a `console.warn` call (if\nsupported by the browser).\n\n```javascript\nvar index = require('/index.js');\n```\n\n#### box.require.ensure(modules, callback)\n\nThis method will ensure that all the modules listed in the `modules` array and\ntheir dependencies will be fetched.\n\nIt is worth noteing that dependencies must be defined reasonably clearly, like:\n\n```javascript\nrequire('string');\n```\n\n_You can check the [detective](https://github.com/substack/node-detective) module\nfor more information on the allowed syntaxes._\n\nWhen done fetching the `callback` will be executed. If an error occurred the\nfirst argument in the `callback` will become an `Error` otherwise its `null`.\n\n```javascript\nbox.require.ensure(['/index.js'], function (err) {\n  if (err) return console.error(err.message);\n\n  var index = require('/index.js');\n});\n```\n\nIt is important to note that resolve errors do not appear in the `error` argument,\nbut are throwen when `require` or `require.resolve` is called just like in node.js.\n\n#### box.require.resolve(module)\n\nThis returns the filepath relative to the `root` specified on the server-side.\nNote that also this method will synchronous if the module isn't already fetched.\n\n```javascript\nconsole.log(require.resolve('async') === '/node_modules/async/index.js');\n```\n\n### Module environment\n\nExcept for the `require.ensure` the module environment is exactly as you known\nit from node.js. The following is exposed:\n\n* `__dirname` the directory name (a unix path)\n* `__filename` the filename (a unix path)\n* `module` the module object, contains `exports`\n* `exports` the object there is returned unless `module.exports` is used.\n* `require` returns the `exports` value of another module\n* `require.resolve` returns the filepath of the module.\n* `require.ensure` prefetch modules.\n\n```javascript\nvar dialog = require('big-box');\n\nmodule.exports = function () {\n  dialog('Hallo World');\n};\n```\n\n## License\n\n**The software is license under \"MIT\"**\n\n> Copyright (c) 2013 Andreas Madsen\n>\n> Permission is hereby granted, free of charge, to any person obtaining a copy\n> of this software and associated documentation files (the \"Software\"), to deal\n> in the Software without restriction, including without limitation the rights\n> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n> copies of the Software, and to permit persons to whom the Software is\n> furnished to do so, subject to the following conditions:\n>\n> The above copyright notice and this permission notice shall be included in\n> all copies or substantial portions of the Software.\n>\n> THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n> THE SOFTWARE.\n","maintainers":[{"name":"andreasmadsen","email":"amwebdk@gmail.com"}],"time":{"modified":"2022-06-20T03:53:22.556Z","created":"2013-01-28T17:23:57.422Z","0.2.0":"2013-01-28T17:24:09.747Z","0.2.1":"2013-03-08T21:52:36.303Z","0.2.2":"2013-04-07T09:27:46.115Z","1.0.0":"2013-08-24T16:10:40.282Z","1.1.0":"2013-08-25T11:50:05.805Z","1.2.0":"2013-08-25T14:31:03.968Z","1.2.1":"2013-08-25T17:13:03.697Z","1.2.2":"2013-08-27T08:04:27.123Z","1.2.3":"2013-08-27T09:50:11.939Z","1.2.4":"2013-08-27T10:02:09.456Z","1.3.0":"2013-08-27T12:02:55.243Z","1.4.0":"2014-01-29T12:17:39.117Z"},"author":{"name":"Andreas Madsen","email":"amwebdk@gmail.com"},"repository":{"type":"git","url":"git://github.com/AndreasMadsen/modulebox.git"},"readmeFilename":"README.md"}