1.0.6 • Published 8 years ago

et-al v1.0.6

Weekly downloads
11
License
Artistic-2.0
Repository
github
Last release
8 years ago

et-al

Easily require all modules in a sub-directory and return them in an array.

Usage

Of course:

npm install --save et-al

Now let's say you have a directory structure like this:

  • my-app.js
  • models/
    • index.js
    • foo.js
    • bar.js

You want to be able to get all your models (excluding index.js) in my-app.js like this:

var models = require('./models');
// models now contains an array of the model modules
// i.e. [foo, bar]

models.forEach(function(model) {
  // do something with it
});

All you have to do is put this line in models/index.js:

module.exports = require('et-al');

Voila!

Coming Soon

Recursive loading and configurable behavior