There are many ways to do what you intend to do.
For example, the easiest way to rewrite any function is to do something like:
Meteor.publish = function() { };
We just rewrote Meteor.publish with our own copy.
However, if you want to wrap the function as a proxy (I believe this is called a "proxy template":
var oldPublish = Meteor.publish(); Meteor.publish = function() { oldPublish(arguments);
ES6 also added a Proxy object that allows you to do some similar things (read about it here ).
There are also many AOPs ( CujoJS , jQuery-AOP and node-aop , to name a few) for JavaScript, which allow you to do before, after, around pointcut on functions / objects. You can even ride yourself if you want.
source share