batch-require

0.1.0 • Public • Published

batch-require

NPM

NPM version Build status

Sometimes we wanna load a batch of module in a directory. When you have such demand, batch-require gives you a good choice.

How to use

├─long_modules
│      path_1_module.js
│      path_2_module.js
│      path_3_module.js
│
├─mocha
│      test.js
const path = require('path')
const {expect} = require('chai');
const batchRequire = require('batch-require');
 
class TestClass {
    constructor(item) {
        for (const key in item) {
            this[key] = item;
        }
    }
}
 
const modules = batchRequire({
    filenameSuffix:'_module.js',
    basePath:path.join(__dirname,'../long_modules'),
    keyReplaces:{'_':'/'}
});
expect(modules).to.have.property('path/1');
expect(modules['path/1']).to.be.an.instanceof(TestClass);

API

See the api document.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i batch-require

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • whyun-master