{"_id":"node-ensure","_rev":"3278271","name":"node-ensure","description":"Async module-loading library and protocol for bundlers/loaders targeting isomorphic apps and Node.js.","dist-tags":{"latest":"0.0.0"},"maintainers":[{"name":"bauerca","email":""}],"time":{"modified":"2024-03-21T16:14:41.000Z","created":"2015-02-28T12:46:37.532Z","0.0.0":"2015-02-28T12:46:37.532Z"},"users":{},"author":{"name":"Carl A. Bauer"},"repository":{"type":"git","url":"https://github.com/bauerca/node-ensure.git"},"versions":{"0.0.0":{"name":"node-ensure","version":"0.0.0","description":"Async module-loading library and protocol for bundlers/loaders targeting isomorphic apps and Node.js.","main":"index.js","browser":{"./index.js":"./browser.js"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["require","ensure","dynamic","module","loader","bundler","async"],"author":{"name":"Carl A. Bauer"},"repository":{"type":"git","url":"https://github.com/bauerca/node-ensure.git"},"bugs":{"url":"https://github.com/bauerca/node-ensure/issues"},"homepage":"https://github.com/bauerca/node-ensure","license":"MIT","gitHead":"a695c69765a5773b638c4e700c7db9d7ae193e13","_id":"node-ensure@0.0.0","_shasum":"ecae764150de99861ec5c810fd5d096b183932a7","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"bauerca","email":"carl.a.bauer@gmail.com"},"maintainers":[{"name":"bauerca","email":""}],"dist":{"shasum":"ecae764150de99861ec5c810fd5d096b183932a7","size":1825,"noattachment":false,"key":"/node-ensure/-/node-ensure-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/node-ensure/download/node-ensure-0.0.0.tgz"},"directories":{},"publish_time":1425127597532,"_hasShrinkwrap":false,"_cnpm_publish_time":1425127597532,"_cnpmcore_publish_time":"2021-12-17T00:02:07.197Z"}},"readme":"# node-ensure\n\nA simple library that shims asynchronous module loading into Node.js to help\nwith building module bundlers and client-side loaders for isomorphic apps.\nThis library is super slim (read the source) and mainly represents an agreement\nbetween developers and users of a particular bundler/loader.\n\nNOTE: This module is *not* compatible with Browserify. It is for developers that\nwant to split their bundles for the client. For example, see\n[dynapack](https://github.com/bauerca/dynapack).\n\n*Syntax is inspired by the CommonJS\n[Modules/Async/A](http://wiki.commonjs.org/wiki/Modules/Async/A) proposal.*\n\n\n## Installation\n\n```\nnpm install node-ensure\n```\n\n## Example\n\n```js\nvar ensure = require('node-ensure');\n\nensure(['superagent', 'react'], function(err) {\n  var request = require('superagent');\n  var React = require('react');\n\n  // Do the coolest of things.\n});\n```\n\nIf your bundler needs `require.ensure`, do this instead:\n\n```js\nrequire.ensure = require('node-ensure');\n\nrequire.ensure(['superagent', 'react'], function(err) {\n  var request = require('superagent');\n  var React = require('react');\n\n  // Do the coolest of things.\n});\n```\n\n## Usage\n\nThe returned function takes an array of strings and a callback, in that\norder (see the example above). The callback takes a single error argument, which\nusually indicates a network problem or other client-side loader-specific runtime\nerror (it should never receive an error when used in Node.js).\n\nWithin the ensure callback, load modules with standard require calls.\n\n## Bundlers/Loaders\n\nThis library primarily constitutes an agreement between users and developers of\nmodule bundlers and (client-side) loaders. The users agree to the usage instructions\nsupplied above.\n\nBundlers and/or loaders must adhere to the following:\n\n- The bundler/loader uses the package.json `\"browser\"` property for replacing\n  server-only modules with browser-ready counterparts (a la Browserify).\n- The `require` function passed to a module must have a `require.ensure`\n  function.\n- Each `require.ensure` must accept the same arguments as described in [Usage](#usage).\n- Each `require.ensure` must not access variables via closure unless those variables\n  are shared by **all** `require.ensure` functions.\n- Each `require.ensure` may access properties\n  on `this`. However, this assumes users have attached node-ensure to `require` via\n  `require.ensure = require('node-ensure')`.\n\nHappy loading!\n\n# License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/bauerca/node-ensure","bugs":{"url":"https://github.com/bauerca/node-ensure/issues"},"license":"MIT"}