An ES7 decorator for making class methods bound to the class instance (including statics).
npm install @aloreljs/bound-decorator
The library's only goal is to be compatible with Typescript 5 decorators which, at the time of writing, use the 2022-03 stage 3 decorators proposal.
import {BoundMethod} from '@aloreljs/bound-decorator';
class MyClass {
@BoundMethod()
method1() {
// equivalent to
// this.method1 = this.method1.bind(this);
}
@BoundMethod('a', 'b')
method2(a, b, c) {
// equivalent to
// this.method2 = this.method2.bind(this, 'a', 'b');
}
@BoundMethod()
static foo() {
// Equivalent to
// MyClass.foo = MyClass.foo.bind(MyClass);
}
}