Socket
Book a DemoInstallSign in
Socket

import-modules-auto

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

import-modules-auto

Import all modules in a directory smart

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

import-modules-auto Build Status

Fork from https://github.com/sindresorhus/import-modules

Add when import Object-Module, merge Object without key-word.

Import all modules in a directory smart

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

Install

$ npm install --save import-modules-auto

Usage

.
└── dir
    ├── foo-bar.js  //function
    └── baz-faz.js  //object {test: 'value'}
const importModules = require('import-modules-auto');
const modules = importModules('dir');

console.log(modules);
//=> {fooBar: [Function], bazFaz: [Function]}
const importModules = require('import-modules-auto');
const modules = importModules('dir',{hasKey: false});

console.log(modules);
//=> {fooBar: [Function], test: 'value'}

API

importModules([directory], [options])

directory

Type: string
Default: __dirname

Directory to import modules from. Unless you've modified require.extensions, 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).

haskey

Type: boolean
Default: true

Can set module without key words, merge object.

  • 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

License

MIT © webkong

Keywords

import

FAQs

Package last updated on 21 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.