1.8.0 • Published 4 years ago
async-modules-loader v1.8.0
async-modules-loader
async-modules-loader is a node.js package for loading npm modules asynchronously with a single function, All you have to give is a single array.
Follow me (@sayanmohsin) on Twitter! Follow me (@sayanmohsin) on github!
- Installation
- Usage
- Simple Usage(#simple usage to run the loadmodules function)
- Configuration Options
- License
- Author
Installation
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install async-modules-loader
Usage
Simple Usage (simple usage to run the loadmodules function)
var aml = require('async-modules-loader');
var aml_options = [{
name: 'passport',
options: {
url: 'passport',
default: true,
moduleName: 'passport'
}
}, {
name: 'cors',
options: {
url: 'cors',
default: false,
moduleName: 'cors'
}
}]
aml.loadModules(aml_options).then(importedModules => {
console.log(importedModules)
}).catch(err => {
console.log(err)
})
// or with async/await
var importedModules = await aml.loadModules(aml_options);
Configuration Options
name
: name of the packageoptions
: Configures the npm packages:url
- name of the npm packagedefault
- set totrue
for automatically importing the default valuemoduleName
- set a dynamic name for the variable to import to. Should follow the basic rules of naming a variable.