[go: up one dir, main page]

import-modules
TypeScript icon, indicating that this package has built-in type declarations

3.2.0 • Public • Published

import-modules

Import all modules in a directory

This package is intentionally simple. Not interested in more features.

Install

$ npm install import-modules

Usage

.
└── directory
    ├── 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) and snake-style names (foo_bar) to camel-case (fooBar).

fileExtensions

Type: string[]
Default: ['.js', '.json', '.node']

File extensions to look for. Order matters.

Related

Package Sidebar

Install

npm i import-modules

Weekly Downloads

388,206

Version

3.2.0

License

MIT

Unpacked Size

5.67 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus