et-al

1.0.6 • Public • Published

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

Package Sidebar

Install

npm i et-al

Weekly Downloads

21

Version

1.0.6

License

Artistic-2.0

Last publish

Collaborators

  • neodon1014