🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@pneugebala/require-as-array

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pneugebala/require-as-array

Requiring all files/directories in given path and returning an array.

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

require-as-array

Build Status

Requiring all files/directories in given path and returning an array.

Installation:

npm install @pneugebala/require-as-array

or

yarn add @pneugebala/require-as-array

Example:

// Directory structure:
//
// entry
// ├───myModule1
// │   └───index.js
// ├───myModule2
// │   └───index.js
// ├───myModule3.js
// └───myModule4.js

const requireAsArray = require("require-as-array")

// Synchronously
const result = requireAsArray("./entry")
...

// Asynchronously
requireAsArray("./entry", (err, result) => {
  if (err)
    throw err
  else
    ...
})

Instead of a nested object, only an array with all required modules is returned.

FAQs

Package last updated on 30 Jan 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