I am new in node.js programming. I need to change behaviour of one function in existing node.js application (Haraka SMTP server).
What is the best practise for doing this? Should I use plugin or is there some another way how to overload one particular JS function in node.js app? Is this even possible?
				
				Node's require caches loaded objects. Therefore you can override an object's function, do something, call the original function, and do something afterwards.
var fs = require('fs');
var origRenameSync = fs.renameSync;
fs.renameSync = function(oldPath, newPath) {
    newPath += ".renamed";
    origRenameSync.call(this, oldPath, newPath);
    // do more here
};
This is a poor example, you should never change core libraries this way. You cannot foresee all side effects.
However, if you know what you do you can adopt existing libraries without changing them internally. It is a very flexible way to decorate functions.