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
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install async-modules-loader
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);
-
name
: name of the package -
options
: Configures the npm packages:-
url
- name of the npm package -
default
- set totrue
for automatically importing the default value -
moduleName
- set a dynamic name for the variable to import to. Should follow the basic rules of naming a variable.
-