async-modules-loader

1.8.0 • Public • Published

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

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 package
  • options: Configures the npm packages:
    • url - name of the npm package
    • default - set to true 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.

License

MIT License

Author

Sayan Mohsin (iamsayanmohsin@gmail.com)

Package Sidebar

Install

npm i async-modules-loader

Weekly Downloads

0

Version

1.8.0

License

ISC

Unpacked Size

9.43 kB

Total Files

5

Last publish

Collaborators

  • sayanmohsin