Advertisement
Guest User

Untitled

a guest
May 29th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. function track(funcName, func) {
  4.   return function () {
  5.     console.log('Tracking method:', funcName, 'with arguments', '[', ...arguments, ']');
  6.     func(...arguments);
  7.     console.log('Tracking done');
  8.   }
  9. }
  10.  
  11. function trackMethods(methods, decl) {
  12.   methods.forEach(method => {
  13.     decl.prototype[method] = track(method, decl.prototype[method]);
  14.   });
  15. }
  16.  
  17.  
  18. class Test {
  19.  
  20.   construct() {
  21.  
  22.   }
  23.  
  24.   sayHello(name = 'Oz') {
  25.     console.log('Hello', name);
  26.   }
  27.  
  28.   test(trackId) {
  29.     console.log('hi', trackId);
  30.   }
  31. }
  32. trackMethods(['test', 'sayHello'], Test);
  33.  
  34. let t = new Test();
  35. t.test(12309823048);
  36. t.sayHello('Martin');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement