| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Transform module source at require-time.
> npm install --save module-map// ./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!MIT
| Back | FazBrowse Home | New Git URL |