0.0.4 • Published 8 years ago

require-mod v0.0.4

Weekly downloads
3
License
BSD-3-Clause
Repository
github
Last release
8 years ago

Require Modifier (require-mod)

RequireMod is a NodeJS-Package which provides the functionality to modify the require-process of a nodejs-module instance.

Installation

This module is installed via npm:

$ npm install require-mod

Usage

Include the ProxyScope constructor:

var ProxyScope = require('require-mod').ProxyScope;

Create a new proxyScope:

var scope = new ProxyScope(module);

Register a redirection:

scope.when(/^fs$/).redirect("fse");

var fse = require("fs"); // the "fse" module instance 

After the regitration the require function of the current module has been modified and loads the registered module-proxy

The Module is also Typescript compatible, you can use the mtype:require-mod to install the definitions.