Created
July 3, 2024 13:47
-
-
Save RichardBray/e63f4ae1b2b2448bc4f650df967c4a24 to your computer and use it in GitHub Desktop.
Revisions
-
RichardBray created this gist
Jul 3, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ function log(originalMethod: any, _context: any) { function replacementMethod(this: any, ...args: any[]) { // const startTime = performance.now(); console.log(`${originalMethod.name} START`); const result = originalMethod.call(this, ...args); console.log(`${originalMethod.name} END`); // const endTime = performance.now(); // console.log(`Method ${originalMethod.name} took ${endTime - startTime} milliseconds`); return "result: " + result; } return replacementMethod; } class Animal { #name: string; constructor(name: string) { this.#name = name; } get name() { return this.#name; } @log makeSound(): string { // let sound = "Sound"; console.log("running makeSound"); // if (this.#name === "Dog") sound = "Bark"; // return sound; return "Sound"; } } const animal = new Animal("Dog"); const sound = animal.makeSound(); console.log(sound);