rwin
Like to keep your requires in the script header?
Tired to load modules that will possibly not been used and overloading your RAM?
Require When I Need is a lightweight tool that loads the required module only when and if you need it!
This Node.js module is under MIT License.
Install :
$ npm install rwin
Usage :
lib = rwin(imports, [dirname]);
Where :
lib
: is an object that contains an accessor for each required modules
imports
: is an object that contains the accessor name paired with the module path
dirname
: is the source path, generally __dirname (useless if You only require installed modules)
Example:
var rwin,imports,lib;rwin = require('rwin');imports = {installedModule: 'installed-module',uninstalledModule: '/uninstalled-module/path'};lib = rwin(imports, __dirname);// At this point, rwin is the only one loaded module (and its own dependencies)console.log(lib.installedModule); // loads the module & returns it to the console