Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function track(funcName, func) {
- return function () {
- console.log('Tracking method:', funcName, 'with arguments', '[', ...arguments, ']');
- func(...arguments);
- console.log('Tracking done');
- }
- }
- function trackMethods(methods, decl) {
- methods.forEach(method => {
- decl.prototype[method] = track(method, decl.prototype[method]);
- });
- }
- class Test {
- construct() {
- }
- sayHello(name = 'Oz') {
- console.log('Hello', name);
- }
- test(trackId) {
- console.log('hi', trackId);
- }
- }
- trackMethods(['test', 'sayHello'], Test);
- let t = new Test();
- t.test(12309823048);
- t.sayHello('Martin');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement