I have this problem that I'm trying to wrap my head around and was wondering if any JS wizards could help me out.
I want to write a factory function that takes a class as an input and returns a new class with all of the same methods as the input class, but with some logging added to each method.
I'm thinking I could loop over each method in the prototype, save the old method, and then reassigned the method to a new function that calls the old method along with the logging as well. However, I'm not sure how I would even get started on this.
Could anyone help me out?