Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

@nhz.io/autoindex



NPM Version


Bithound Status


License


Downloads

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)