mlo
v1.1.0
Published
Simple Module Loader
Downloads
7
Readme
mlo
Simple module loader for Node.js
Installation
npm install mlo
Examples
directories
app.js
lib/module_a.js
module_b.js
mod-c.js
mod-d/index.js
mod-e.js
node_modules
package.json
Basic usage
app.js
var mlo = require("mlo");
var lib = mlo("lib").load();
lib.module_a //= require("./lib/module_a")
lib.module_b //= require("./lib/module_b")
lib["mod-c"] //= require("./lib/mod-c")
Advanced usage [pattern]
pattern matches filename
ref: isaacs/minimatch
app.js
var mlo = require("mlo");
var lib = mlo("lib").load("module_*");
lib.module_a //= require("./lib/module_a")
lib.module_b //= require("./lib/module_b")
Advanced usage [recursively]
load module recursively
app.js
var mlo = require("mlo");
var lib = mlo("lib").loadRecursively("mod_*");
// alias: mlo("lib").loadr("mod_*");
lib["mod-c"] //= require("./lib/mod-c")
lib["mod-d"]["mod-e"] //= require("./lib/mod-d/mod-e")