1.0.4 • Published 2 years ago
@paukuman/autoloader v1.0.4
Autoloader
This is a autoloader modules like PHP autoloader
Installation
Install autoloader with npm
npm install fs fs.promises
npm install @paukuman/autoloader
How to use it
(async function() => {
/* [ Autoloader Modules ] */
const autoloader = require('@paukuman/autoloader');
// modules installed
const packages = `${__dirname}/package.json`;
// local modules
const locals = `${__dirname}/plugins`;
/* [ Configuration ] */
await autoloader(packages, locals);
})();
so
// example if you want to see all installed modules
console.log(m);
// example if you have installed express
const app = m.express;
app.get('/', (req, res) => {
res.send('Hello World');
})
// example if you have installed fs.promises
console.log(await m['fs.promises'].readdir(args[1]));