$ cnpm install import-modules
Import all modules in a directory
This module is intentionally simple. Not interested in more features.
$ npm install import-modules
.
└── dir
├── foo-bar.js
└── baz-faz.js
const importModules = require('import-modules');
const modules = importModules('directory');
console.log(modules);
//=> {fooBar: [Function], bazFaz: [Function]}
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 _
.
Type: object
Type: boolean
Default: true
Convert dash-style names (foo-bar
) to camel-case (fooBar
).
Type: string[]
Default: ['.js', '.json', '.node']
File extensions to look for. Order matters.
Copyright 2013 - present © cnpmjs.org