0.0.8 • Published 10 years ago

require-children v0.0.8

Weekly downloads
4
License
ISC
Repository
github
Last release
10 years ago

Require Children

Easily and safely require a directory as an object whose keys are its children's filenames (without their extensions), and whose values are its children as modules.

Example

To require a directory resources/ with children posts.js, comments.js, and users.js:

var resources = requireChildren('./resources', module);

/**
 * Now all modules contained in ./resources/ are in the object:
 *
 * resources = {
 *   comments: [object Object],
 *   posts: [object Object],
 *   users: [object Object]
 * } 
 */

Installation

npm install require-children

Usage

requireChildren(directory, destinationModule);

requireChildren always returns a children object. The keys of the children object are the names of the modules that were successfully loaded from directory without their extensions or any spaces.

params

  • directory: The directory to require children of.
  • destinationModule: The module that is requiring the directory children.
0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago