Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grequire

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

grequire

Synchronous require of multiple modules that match a given glob pattern

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

This module provides a way to synchronously load multiple Node.js modules using glob pattern matching.

Example

Require all sibling modules (relative to this module):

var results = grequire(module, "./*.js")

console.log(results)

Output:

[{
  filename: './sibling-1.js',
  exports: { /* exports of sibling-1 */ }
}, {
  filename: './sibling-2.js',
  exports: { /* exports of sibling-2 */ }
}]

Also see the spec, it shows many different combinations of parameters, with comments.

API

grequire([module, ] pattern [, globOpts])
  • module The module object that requires should be performed on behalf of. Usually this should be the free module variable, like in the example above.

  • pattern, globOpts The glob pattern and options to use when matching files. See the node-glob documentation.

Returns an array of items, where each item corresponds to one required module, and has the following contents:

{
  /**
   * The filename of the loaded module. It may be absolute or relative,
   * depending on the pattern. See test/index.js for examples.
   */
  filename: String,
  /**
   * The loaded module's exports.
   */
  exports: AnyObject
}

ES6

This module is written in ES6, and ES5 code is generated using Babel.

If you live in the future or use Babel (or some other transpiler), you may want to load the non-transpiled ES6 code:

import grequire from 'grequire/es6'

License

MIT

Keywords

FAQs

Package last updated on 04 Apr 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