Hello,
I'm trying to override function implementation where original function is 
part of nodejs module (myMod.js):
'use strict';
function doSomething(req,res) {
 console.log('internal');
}
function doSomethingElse(req,res) {
 doSomething(req,res);
}
module.exports.doSomething=doSomething;

I can override doSomething from the outside:
var myMod = require('myMod.js');
myMod.doSomething = function(req,res) {
 console.log('external');
};

And when I call doSomething new implementation is used (prints 'external').
But when I call doSomethingElse it still prints 'internal' - it looks like 
inside the module original implementation is used.

I saw a post that suggested declaring a variable (inside module):
var doSomehing = module.exports.doSomething = doSomething;

But using that didn't help.
Any suggestions on how to replace doSomething so that calling 
doSomethingElse prints 'external'?
Thanks,

M

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/e23dace9-3cba-4499-aca1-da2f850b1428%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to