Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nhz-io/autoindex
Autoindex directory (require) with custom loader
https://github.com/nhz-io/autoindex
Last synced: 3 days ago
JSON representation
Autoindex directory (require) with custom loader
- Host: GitHub
- URL: https://github.com/nhz-io/autoindex
- Owner: nhz-io
- License: mit
- Created: 2016-09-17T21:18:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-17T21:20:43.000Z (over 8 years ago)
- Last Synced: 2024-08-08T22:19:18.987Z (5 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
@nhz.io/autoindex
Autoindex directory (require) with custom loader
## Install
```shell
npm i -S @nhz.io/autoindex
```## Usage
```javascript
const ai = require('@nhz.io/autoindex')module.exports = ai(__dirname, glob, loader)
...
```## Example
```javascript
/** +-+
* +- index.js
* +- a.js
* +- b.js
*/// File: index.js
const ai = require('@nhz.io/autoindex')module.exports = ai(__dirname) // a.js and b.js are autorequired and exported
```## Notes
* `glob` and `loader` are optional
* Default `glob` is: `*.+(js|json)`
* Default loader will skip `index.*` files
* Custom `loader` will receive the path of the matching module as a first argument## License
### [MIT](LICENSE)