javascript - Is it possible to override a module in CJS or NodeJS? -


i importing module in application using 'require'. , want change functionality of module in js file , starting step, if require module, changed chings should affect. possible achieve this? not exact this.

//module1.js module.exports = function(p,q) { retrun p+q; }  //app.js  var change  = require(./module1);// 'require'd here modify,actually there no dependency var dependency = require(./dependency1)  //modifying module1 functionality  // module.exports = function() {return p-q;}  //dependency1.js var use1 = require(./module1) log(use1(8,3))// should result in '5'  enter code here 

any ais highly appreciable. thankyou


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -