Last active
August 29, 2024 13:30
-
-
Save devotdev/a326d0a2e2ba39267afb3652ed65f269 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function log(target: any, methodName: string, descriptor: PropertyDescriptor) { | |
| const originalMethod = descriptor.value; | |
| descriptor.value = function (...args: any[]) { | |
| console.log(Method ${methodName} called with arguments: ${JSON.stringify(args)}); | |
| console.log(`State before method ${methodName}: ${JSON.stringify(this)}`); | |
| const result = originalMethod.apply(this, args); | |
| console.log(Method ${methodName} returned: ${JSON.stringify(result)}); | |
| return result; | |
| }; | |
| return descriptor; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment