Execute a function on each module in a directory.
Current Version: 1.0.
7152
0
Node Support: 0.10.x, 0.11.x
License: MIT
Build Status:
eachModule('./examples', function (name, mod) {
// name = the name of the loaded module
// mod = the module's exports
});Install EachModule with npm:
npm install each-module// Load EachModule
var eachModule = require('each-module');
// Find/load all JavaScript/CoffeeScript modules
// in the `examples` folder
eachModule('./examples', function (name, mod) {
// This function is run for each module:
// name = the name of the loaded module
// mod = the module's exports
});Note: EachModule loads modules synchronously only, so it's best used in your application's startup – it's blocking.
To contribute to EachModule, clone this repo locally and commit your code on a separate branch.
Please write unit tests for your code, and check that everything works by running the following before opening a pull-request:
make lint testEachModule is licensed under the MIT license.
Copyright © 2014, Rowan Manning