Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

them

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Issues
File Explorer

Advanced tools

them

Easier node require

    0.0.4latest
    npm

Version published
Maintainers
1
Weekly downloads
549
increased by36.91%

Weekly downloads

Readme

Source

Demo example

Instead of doing this

var http = require('http'), myModule = require('./lib/myModule'), User = require('./lib/models').User; // rest of your code

you do

require("them")(function(http, myModule, User) { // rest of you code })

The goals I wanted to achieve with this library

  • Avoid redundand pattern of require
  • Have centralized, relative to the root require
  • Contistent naming across my application
  • Configurable require for test and coverage
  • Stop the "where the comma should go" debate

Warning before use

  • Do not use in libraries or modules, but you can safely use it in your application.
  • This library is quite young, please be careful and patient.

Installation

npm install them --save

Initialization

You must initialize them before you use it, because you have to tell what is your root module and all the required modules should be relative to that.

require('them').init(module, [mapping]);
  • module: do not change it, you have to pass the module
  • mapping: a simple which contains mapping between name and module if it doesn't match.

Example:

require('them').init(module, { _: "underscore", email: "./services/email", User: "./models/models#User", });

Usage

Example

require("them")(function(http, _, email, User) { // you code });

Features

  • Automatically require module based on the parameter name
  • You have to configure manually your own submodules to be requirable, by default it search from the ./lib/ directory
  • You can change the default library directory with THEM_LIB environment variable. It's useful for coverage

Keywords

FAQs

Last updated on 24 Mar 2013

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc