{ "author": { "name": "Ben Newman", "email": "bn@cs.stanford.edu" }, "name": "install", "description": "Minimal JavaScript module loader", "keywords": [ "modules", "require", "commonjs", "exports", "browser", "packaging", "packager", "install" ], "version": "0.1.7", "homepage": "http://github.com/benjamn/install", "repository": { "type": "git", "url": "git://github.com/benjamn/install.git" }, "main": "main.js", "scripts": { "test": "whiskey test/run.js" }, "optionalDependencies": { "whiskey": "0.6.x" }, "engines": { "node": ">= 0.6" }, "readme": "Introduction\n---\n\nThe [CommonJS module syntax](http://wiki.commonjs.org/wiki/Modules/1.1) is one of the most widely accepted conventions in the JavaScript ecosystem. Everyone seems to agree that `require` and `exports` are a reasonable way of expressing module dependencies and interfaces, and the tools for managing modular code are getting better all the time.\n\nMuch less of a consensus has developed around the best way to deliver CommonJS modules to a web browser, where the synchronous semantics of `require` pose a non-trivial implementation challenge. This module loader contributes to that confusion, yet also demonstrates that an amply-featured module loader need not stretch into the hundreds or thousands of lines.\n\nInstallation\n---\nFrom NPM:\n\n npm install install\n\nFrom GitHub:\n\n cd path/to/node_modules\n git clone git://github.com/benjamn/install.git\n cd install\n npm install .\n\nUsage\n---\n\nWhen evaluated, the contents of install.js create a global function called `install`. This function is the only external interface to the module loader, and it can be called in two ways.\n\nThe first way is to pass a module identifier string followed by a module factory function:\n\n install(\"some/module/id\", function(require, exports, module) {\n // CommonJS module code goes here.\n\n // For example:\n exports.setImmediate = function(callback) {\n return setTimeout(callback, 0);\n };\n });\n\nThis makes the module available for requirement, but does not evaluate the contents of the module until the first time another module calls `require(\"some/module/id\")`.\n\nThe second way to invoke `install` is to omit the module identifier and pass an anonymous module factory function:\n\n install(function(require) {\n // Code that uses require goes here.\n\n // For example:\n require(\"some/module/id\").setImmediate(function() {\n console.log(\"setImmediate fired\");\n });\n });\n\nAnonymous modules are executed in order of installation, as soon as their requirements have been installed. Note that such modules do not have exports objects, because anonymous modules cannot be required.\n\nSugar\n---\nIf a named module has no requirements and does not need its own scope, the following shorthand can be used to install the module:\n\n install(\"simple/module\", { exports: {\n one: 1,\n two: 2,\n buckle: \"my shoe\"\n }});\n", "readmeFilename": "README.md", "_id": "install@0.1.7", "dependencies": { "whiskey": "0.6.x" }, "dist": { "shasum": "30a90982c625506cb60c33f2a002db979a09b0ea", "tarball": "http://registry.npmjs.org/install/-/install-0.1.7.tgz" }, "_from": "install@^0.1.7", "_npmVersion": "1.2.10", "_npmUser": { "name": "benjamn", "email": "bn@cs.stanford.edu" }, "maintainers": [ { "name": "benjamn", "email": "bn@cs.stanford.edu" } ], "directories": {}, "_shasum": "30a90982c625506cb60c33f2a002db979a09b0ea", "_resolved": "https://registry.npmjs.org/install/-/install-0.1.7.tgz", "bugs": { "url": "https://github.com/benjamn/install/issues" } }