title: How to execute a function before and after each class method call?
body: <p>I want to insert on pre execute and post execute hooks on functions in javascript classes.</p>
  
  <p>Lets say I have a class like this.</p>
  
  <pre class="lang-js prettyprint-override"><code>class Foo {
    method1(p1, p2) {
      this.p1 = p1;
      this.p2 = p2;
    }
  
    method2(p3) {
      this.p3 = p3;
    }
  }
  </code></pre>
  
  <p>I want to define a before and after hook for these preexisting class methods. Something like this.</p>
  
  <pre class="lang-js prettyprint-override"><code>class Foo {
    before(funName, ...params){
      // Should print ('method1', [p1, p2]) when method 1 is called
      // and ('method2', [p3]) when method 2 is called
      console.log(funName, params)
    }
    after(funName, result){
      // Should print the function name followed by its result
      console.log(funName, result)
    }
    method1(p1, p2) {
      this.p1 = p1;
      this.p2 = p2;
    }
    method2(p3) {
      this.p3 = p3;
    }
  }
  
  export default Foo;
  </code></pre>
  
  <p>What is the best way of implementing these hooks with minimal changes in existing code?</p>