1.0.0 • Published 5 years ago
requirejs-helper v1.0.0
@jkinfeng/requirejs-helper
Autoload js file of Node.js
Installation
npm i requirejs-helper
API Reference
Param | Type | Default Value | Description |
---|---|---|---|
$options | Object | ||
$options.path | String | process.cwd() | js file base path |
$options.regular | Regular expression | /\.js$/ | js file match |
Example
Basic usage:
const requireJs = require('requirejs-helper');
// returns an object, Null object if no jsfile is loaded.
const obj = requireJs({
path: 'path',
regular: /\.js$/
});
// Call mode
// obj.filename.doSomething
// filename: name of js file
// doSomething: object, function or both
// Suppose you load a js file that contains an object and a function
// myFunc.js
// ============================================
// module.exports = {a: 123, b: function(){return 'b'}}
// ============================================
// Object-Call: obj.myFunc.a
// Function-Call: obj.myFunc.b()
// Tips: the dots contained in the file name are replaced by underscores
// my.func.js => obj.my_func
Contributing
Please submit all issues and pull requests to the jkinfeng/requirejs-helper repository!
Support
If you have any problem or suggestion please open an issue here.
License
1.0.0
5 years ago