Socket
Socket
Sign inDemoInstall

require-dir

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-dir

Helper to require() directories.


Version published
Weekly downloads
233K
decreased by-1.72%
Maintainers
1
Weekly downloads
 
Created

What is require-dir?

The require-dir npm package allows you to require all files in a directory, making it easier to manage and load multiple modules without having to require each one individually.

What are require-dir's main functionalities?

Basic Usage

This feature allows you to require all files in a specified directory. The returned object will have keys corresponding to the filenames and values being the required modules.

const requireDir = require('require-dir');
const modules = requireDir('./path/to/directory');

Recursive Loading

This feature allows you to recursively require all files in a directory and its subdirectories. The returned object will have nested objects corresponding to the directory structure.

const requireDir = require('require-dir');
const modules = requireDir('./path/to/directory', { recurse: true });

Filtering Files

This feature allows you to filter which files to require based on a custom filter function. In this example, only files ending with '.js' will be required.

const requireDir = require('require-dir');
const modules = requireDir('./path/to/directory', { filter: (filename) => filename.endsWith('.js') });

Other packages similar to require-dir

FAQs

Package last updated on 20 Mar 2015

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc