Skip to content

yunnysunny/batch-require

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published