I'm trying to override Node.js require function. However in JavaScript functions can have values and properties
Assuming code like this
a = function() {};
a.someParam1 = 1;
a.someParam2 = 2;
If I console log it. It'd look like:
{ [Function] someParam1: 1, someParam2: 2 }
I know I can call this function by simply doing
a()
But what If I wanted to override it's behavior without getting rid of properties?
Doing
a = function(){ console.log("Some other function")}
console.log(a.someParam1)
would yield undefined.
How can I override function value without touching it's parameters?
require()is not a good idea. What are you trying to accomplish?console.log("Some other function"... but i guess that was just a typo... ;)