How to wrap function with multiple arguments where some arguments are optional ?
https://github.com/sstephenson/prototype/blob/d9411e5/src/prototype/lang/function.js#L337
Here is how i did it
var Order = new Class.create();
Order.prototype = {
initialize : function(data){
},
// here arg3 and arg4 are optional parameter
submit : function(arg1,arg2,arg3,arg4){
console.log(arg1);
console.log(arg2);
console.log(arg3);
console.log(arg4);
}
};
above class is defined in some third party library and below is how i have wrap it.
is this correct way to do it ?
Order.prototype.submit = Order.prototype.submit.wrap(function(callOriginal,arg1,arg2,arg3,arg4) {
//call my custom code here;
callOriginal(arg1,arg2,arg3,arg4);
});