function s({before,myFunc,after}) {
function proxy(method) {
return function () {
try{
before && before.apply(this,arguments);
method.apply(this,arguments);
after && after.apply(this,arguments);
}catch (e) {
console.error(e);
}finally {
}
}
}
for(var kin myFunc.prototype){
myFunc.prototype[k]=proxy(myFunc.prototype[k])
}
}
function MyFunc(name) {
this.name=name;
}
MyFunc.prototype.t =function () {
console.log(this,arguments);
};
s({
before:function () {
console.log("before");
},
myFunc:MyFunc,
after:function () {
console.log("after");
}
});
var f =new MyFunc("asfsfsdf");
var f1 =new MyFunc("2423423423")
f.t(1,2,3,4,5);
f1.t(8,9);