How could I implement a decorator that makes all methods of a class automatically chainable?
I have the following class:
class MyClass {
async foo() { console.log(1); }
async bar() { console.log(2); }
}
I want to be able to do the following:
@chainableMethods
class MyClass {
...
}
const myInstance = MyClass();
myInstance
.foo()
.bar();