https://github.com/krolow/require-dir-as-map
Require a whole directory as a Javascript Map
https://github.com/krolow/require-dir-as-map
module nodejs require
Last synced: 2 months ago
JSON representation
Require a whole directory as a Javascript Map
- Host: GitHub
- URL: https://github.com/krolow/require-dir-as-map
- Owner: krolow
- License: mit
- Created: 2017-05-11T22:10:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-12T01:01:11.000Z (about 8 years ago)
- Last Synced: 2024-04-24T20:42:39.934Z (about 1 year ago)
- Topics: module, nodejs, require
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/require-dir-as-map
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# require-dir-as-map
[](https://travis-ci.org/krolow/require-dir-as-map)
[](http://badge.fury.io/js/require-dir-as-map)> Require a directory and get back a `new Map()`
### Usage
```js
const requireDirAsMap = require('require-dir-as-map');const filter = (file) => {
return file;
};const map = ({ file, module }) => {
return module.somethingThere || file.split('.')[0];
}requireDirAsMap('/my-directory/', { filter, map });
```
## License
Licensed under The MIT License
Redistributions of files must retain the above copyright notice.## Author
Vinícius Krolow - krolow[at]gmail.com