AspectJS

Aspects = function(){};
Aspects.prototype={
  before:function(method,advice){
	
	
    var original  = this[method];
    this[method] = function(){
      (advice)();
      original.apply(this,arguments);
    }
  },
  after:function(method,advice){
    var original  = this[method];
    this[method] = function(){
      original.apply(this,arguments);
      var args = method;
      advice.call(original,method);
    }
  },
  around:function(method,advice){
    var original  = this[method];
    this[method] = function(){
      (advice)();
       original.apply(this,arguments);
      (advice)();
    }
  }
}

原文地址:https://www.cnblogs.com/wblade/p/1887953.html