You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
5 years ago | |
|---|---|---|
| .. | ||
| index.js | 5 years ago | |
| license | 5 years ago | |
| package.json | 5 years ago | |
| readme.md | 5 years ago | |
readme.md
import-modules 
Import all modules in a directory
This module is intentionally simple. Not interested in more features.
Install
$ npm install import-modules
Usage
.
└── dir
├── foo-bar.js
└── baz-faz.js
const importModules = require('import-modules');
const modules = importModules('directory');
console.log(modules);
//=> {fooBar: [Function], bazFaz: [Function]}
API
importModules(directory?, options?)
directory
Type: string
Default: __dirname
Directory to import modules from. Unless you've set the fileExtensions option, that means any .js, .json, .node files, in that order. Does not recurse. Ignores the caller file and files starting with . or _.
options
Type: object
camelize
Type: boolean
Default: true
Convert dash-style names (foo-bar) to camel-case (fooBar).
fileExtensions
Type: string[]
Default: ['.js', '.json', '.node']
File extensions to look for. Order matters.
Related
- import-from - Import a module from a given path
- import-cwd - Import a module from the current working directory
- import-lazy - Import a module lazily