Socket
Book a DemoInstallSign in
Socket

module-map

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

module-map

Transform module source at require-time.

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
2
Created
Source

module-map

Transform module source at require-time.

Installation

> npm install --save module-map

Usage

// ./some/module.js

module.exports = function() {
  return 'Hello World'
}
// index.js

var ModuleMap = require('module-map')(__dirname)

ModuleMap(function(content, filename) {
  // modify the source code!
  return content.replace('Hello World', 'HELLO WORLD')
})

// functions are applied in order
ModuleMap(function(content, filename) {
  return content.replace('HELLO WORLD', 'HELLO WORLD!')
})

// elsewhere...

var hello = require('./some/module')
console.log(hello()) // HELLO WORLD!

Caveats

  • Does not work with .json files, or any custom require extension that produces JSON output e.g. require-yaml

License

MIT

FAQs

Package last updated on 29 Apr 2014

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